📜  trhow exception if is null c# Code Example

📅  最后修改于: 2022-03-11 14:48:39.347000             🧑  作者: Mango

代码示例1
public Exception GetException(object instance)
{
    return (instance == null) ? new ArgumentNullException() : new ArgumentException();
}

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