Answers for "trhow exception if is null c#"

C#
0

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);
}
Posted by: Guest on August-24-2020
0

trhow exception if is null c#

var firstName = name ?? throw new ArgumentException("Mandatory parameter", nameof(name),);
Posted by: Guest on August-24-2020

C# Answers by Framework

Browse Popular Code Answers by Language