NumberStyles.None
using System;
using System.Globalization;
public class StringParsing
{
public static void Main()
{
string numericString;
NumberStyles styles;
numericString = "-30677";
styles = NumberStyles.None;
CallTryParse(numericString, styles);
}
private static void CallTryParse(string stringToConvert, NumberStyles styles)
{
Console.WriteLine(stringToConvert);
short number;
bool result = Int16.TryParse(stringToConvert, styles,CultureInfo.InvariantCulture, out number);
if (result)
Console.WriteLine(stringToConvert, number);
else
Console.WriteLine("failed.");
}
}
Related examples in the same category