trhow exception if is null c#

80

trhow exception if is null c# -

public Exception GetException(object instance)
{
    return (instance == null) ? new ArgumentNullException() : new ArgumentException();
}

public void Main()
{
    object something = null;
    throw GetException(something);
}

Comments

Submit
0 Comments