Created
May 10, 2021 02:27
-
-
Save ufcpp/9bbce01cdbed7b4266e488cd55e8a8e6 to your computer and use it in GitHub Desktop.
static っぽく見えるけどインスタンスメソッドが生成されることがあるやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
class Program | |
{ | |
static void Main() | |
{ | |
Action a1 = M; | |
Console.WriteLine(a1.Method.IsStatic); // true | |
Action a2 = static () => { }; | |
Console.WriteLine(a2.Method.IsStatic); // false。ラムダ式の仕様。インスタンスメソッドの方が速いからインスタンスメソッドで生成してしまう。 | |
Action a3 = local; | |
Console.WriteLine(a3.Method.IsStatic); // true | |
static void local() { } | |
} | |
static void M() { } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment