OverflowException: Value was either too large or too small for an int32

Problem When you try to convert a string to an integer with int.Parse() (or Convert.ToInt32()), you get the following exception: System.OverflowException: Value was either too large or too small for an Int32. The problem is the integer value in the string can’t fit in the 32-bit integer. Int32 (int) can only hold values between -2147483648 … Read more

C# – Convert string list to int list

You can convert a list of strings to a list of integers by using int.Parse() on all of the strings. There are two simple ways to do this: I’ll show examples of these using these methods and then explain how to handle parsing exceptions. Option 1 – Use List.ConvertAll() Here’s an example of how to … Read more