Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
C# OverflowException
OverflowException is thrown when the parameter value is out of integer ranges.
Let us see an example.
When we set a value to int.Parse() method that is out of integer range, then OverflowException is thrown as shown below −
Example
using System;
class Demo {
static void Main() {
string str = "757657657657657";
int res = int.Parse(str);
}
}
Output
The following error is thrown when the above program is compiled since we have passed a value that is out of integer (Int32) range.
Unhandled Exception: System.OverflowException: Value was either too large or too small for an Int32.
Advertisements
