TryParse(String, Int32) Converts the string representation of a number to its 32-bit signed integer equivalent. A return value indicates whether the conversion succeeded.
How do you use TryParse?
How to use int. TryParse
- public static void Main(string[] args)
- {
- string str = "";
- int intStr; bool intResultTryParse = int.TryParse(str, out intStr);
- if (intResultTryParse == true)
- {
- Console.WriteLine(intStr);
- }
What does TryParse return?
TryParse is a static data conversion method that allows to convert a string value to a corresponding 32-bit signed integer value. It returns a Boolean True value for successful conversion and False in case of failed conversion.