Brandon Sides
6
Q:

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);
}
0
var firstName = name ?? throw new ArgumentException("Mandatory parameter", nameof(name),);
0

New to Communities?

Join the community