0
このコードを書く方が良いですか?この方法はとても複雑に見えます。 anotherVariable
に応じてexample
の値を割り当てたいとします。C言語で匿名メソッドを呼び出すよりクリーナーな方法#
var example = new Func<DateTime>((() =>
{
switch (anotherVariable)
{
case "Jesus birth": return new DateTime(0, 12, 24);
case "Second condition": return new DateTime(2017, 23, 11);
// etc
default: return DateTime.Now;
}
})).Invoke();
それはそれです。ありがとう! –