Created
January 27, 2021 15:11
-
-
Save ShekharReddy4/82650fa0918891a08a4996bc7d0695eb to your computer and use it in GitHub Desktop.
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
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment