IsInteger
Returns true if the given string can be parsed into an integer, false otherwise.
- Return the result of calling
Double.TryParse()withNymberStyles.Integerfor the givennumstring. - Use
Double.TryParse()to allow handling of values larger thanInt64.
using System.Globalization;
public static partial class _30s
{
public static bool IsInteger(string num)
{
Double _ = 0.0;
return Double.TryParse(num, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out _);
}
}_30s.IsInteger("2"); // true
_30s.IsInteger("3.1"); // false