C# 7.0からの引数nullチェック
破棄
と null合体演算子
を使ってワンライナーnullチェックが行えます
void testMethod(object arg)
{
_ = arg ?? throw new ArgumentNullException();
// 以下処理
:
}
https://docs.microsoft.com/ja-jp/dotnet/csharp/language-reference/operators/null-coalescing-operator
https://docs.microsoft.com/ja-jp/dotnet/csharp/fundamentals/functional/discards