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.

Revisions

  1. ShekharReddy4 created this gist Jan 27, 2021.
    56 changes: 56 additions & 0 deletions test.cs
    Original 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
    }