Created
January 27, 2021 15:11
-
-
Save ShekharReddy4/82650fa0918891a08a4996bc7d0695eb to your computer and use it in GitHub Desktop.
Revisions
-
ShekharReddy4 created this gist
Jan 27, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ delegate void Printer(); static void Main() { List<Printer> printers = new List<Printer>(); int i=0; for(; i < 10; i++) { printers.Add(delegate { Console.WriteLine(i); }); } foreach (var printer in printers) { printer(); } } public class TestStatic { public static int TestValue; public TestStatic() { if (TestValue == 0) { TestValue = 5; } } static TestStatic() { if (TestValue == 0) { TestValue = 10; } } public void Print() { if (TestValue == 5) { TestValue = 6; } Console.WriteLine("TestValue : " + TestValue); } } public void Main(string[] args) { TestStatic t = new TestStatic(); t.Print();//10 }