Implement a Custom Event Argument - CSharp Custom Type

CSharp examples for Custom Type:Event

Description

Implement a Custom Event Argument

Demo Code


using System;//from w  w w . j  a va2  s.  c  o  m

    [Serializable]
    public sealed class MailReceivedEventArgs : EventArgs
    {
        private readonly string from;
        private readonly string subject;

        public MailReceivedEventArgs(string from, string subject)
        {
            this.from = from;
            this.subject = subject;
        }

        public string From { get { return from; } }
        public string Subject { get { return subject; } }
    }

class MainClass
    {
        public static void Main()
        {
            MailReceivedEventArgs args = new MailReceivedEventArgs("YourName", "Your book");

            Console.WriteLine("From: {0}, Subject: {1}", args.From, args.Subject);
        }
    }

Related Tutorials