Skip to content

Instantly share code, notes, and snippets.

@ShekharReddy4
Created January 27, 2021 15:11
Show Gist options
  • Save ShekharReddy4/82650fa0918891a08a4996bc7d0695eb to your computer and use it in GitHub Desktop.
Save ShekharReddy4/82650fa0918891a08a4996bc7d0695eb to your computer and use it in GitHub Desktop.
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