Throw exception in c#

Throw exception in c#

 

using System; 
class usingcsharp
 { 
    static string b = null;  
    static void displaymsg(string a) 
    { 
        if (a  == null) 
            throw new NullReferenceException("Exception Found.");              
    }    
static void Main(string[] args) 
{  
    try
    { 
        displaymsg(b); 
    }  
    catch(Exception ex) 
    { 
        Console.WriteLine( ex.Message ); 
    }                      
} 
}

 

 

2021-10-03