BalloonsPop.Common.Gadgets.StringExtensions.ToInt32 C# (CSharp) Method

ToInt32() public static method

Converts the provided string to an INT32, throwing an exception in case of invalid string format.
public static ToInt32 ( this str ) : int
str this The string to be parsed to INT32.
return int
        public static int ToInt32(this string str)
        {
            int result = 0;
            bool successfulParse = int.TryParse(str, out result);

            if (!successfulParse)
            {
                throw new ArgumentException("String value was not in a valid parse from for an integer");
            }

            return result;
        }
StringExtensions