- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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