C# Delegate List

[TestFixture]
public class TestDelegate
{
    public delegate void SampleDelegate();
    List<SampleDelegate> SampleDelegates = new List<SampleDelegate>();
    [Test]
    public void Test()
    {
        SampleDelegates.Add(Sample1);
        SampleDelegates.Add(Sample2);
        foreach (SampleDelegate sampleDelegate in SampleDelegates)
        {
            sampleDelegate();
        }
    }
    public void Sample1()
    {
        Console.WriteLine("Sample 1");
    }
    public void Sample2()
    {
        Console.WriteLine("Sample 2");
    }
}

Comments

Popular posts from this blog

Tibco Rendezvous (tibrv) C# .Net example

Parse XML to dynamic object in C#