Sumitra Paul

Sumitra Paul

  • NA
  • 51
  • 33.7k

passing only one string value from an event

Mar 25 2013 11:24 AM

Hi,

I am new to c#. I am using an event.

Please see the below code.

public interface IMyTest
    {
        event EventHandler<PersonDetailsEventArgs> Save;
    }

    public class MyTest : IMyTest
    {
        public event EventHandler<PersonDetailsEventArgs> Save;

        public void MyMethod()
        {
            // calling save event
            Save(this, new PersonDetailsEventArgs("sss", "AAA"));
        }
    }

    public class PersonDetailsEventArgs : EventArgs
    {
        public string ID { get; set; }
        public string Name { get; set; }

        public PersonDetailsEventArgs(string name, string Id)
        {
            Name = name;
            ID = Id;
        }
    }


I am passing PersonDetailsEventArgs as with two string values.

actually i just want to pass Id.

My question is, is it that for passin gonly Id also I need to create
PersonDetailsEventArgs class.

I don'nt want to create this as I have to pass only one string value.

I am sure i can do this without PersonDetailsEventArgs class. But dnt know how.

Please let me know how I can do this.


Answers (1)