bool IsDigitsOnly(string str)
{
foreach (char c in str)
{
if (c < '0' || c > '9')
return false;
}
return true;
}
Will probably be the fastest way to do it.
More Related Contents:
- Is String.Contains() faster than String.IndexOf()?
- String concatenation vs String Builder. Performance
- String interning in .Net Framework – What are the benefits and when to use interning
- String Interpolation vs String.Format
- Does String.GetHashCode consider the full string or only part of it?
- A better way to replace many strings – obfuscation in C#
- A fast hash function for string in C#
- Does any one know of a faster method to do String.Split()?
- Fastest way to remove first char in a String
- Why .NET String is immutable? [duplicate]
- Escape double quotes in a string
- Why would you use String.Equals over ==? [duplicate]
- Make first letter of a string upper case (with maximum performance)
- Efficient way to remove ALL whitespace from String?
- How do I write a backslash (\) in a string?
- Need to perform Wildcard (*,?, etc) search on a string using Regex
- string.IsNullOrEmpty(string) vs. string.IsNullOrWhiteSpace(string)
- File.Copy vs. Manual FileStream.Write For Copying File
- @(at) sign in file path/string [duplicate]
- C# equivalent to Java’s charAt()?
- How to capitalize the first character of each word, or the first character of a whole string, with C#?
- What is the correct way to compare char ignoring case?
- Convert XmlDocument to String
- Do string literals get optimised by the compiler?
- How do I format a Decimal to a programatically controlled number of decimals in c#?
- Why is this F# code so slow?
- Is it better to execute many sql commands with one connection, or reconnect every time?
- Convert String^ in c# to CString in c++/CLI
- SQL Server: Dynamic where-clause
- Parsing formatted string