![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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
ArgumentNullException in C#
The exception thrown when a null reference is passed to a method that does not accept it as a valid argument.
Let us see an example.
When we set a null parameter to int.Parse() method, then ArgumentNullException is thrown as shown below −
Example
using System; class Demo { static void Main() { string val = null; int res = int.Parse(val); // error is thrown } }
Output
The following error is thrown when the above program is compiled since we have passed a null value.
Unhandled Exception: System.ArgumentNullException: Value cannot be null.
Advertisements