I have project, where is Client class. I want to have an event for creation a Client's object. I read information about events but I still in a fog how to use events This is my code:
public class Client
{
public string FirstName { get; set; }
public string SecondName { get; set; }
public string DateOfBirth { get; set; }
public string Address { get; set; }
public Client(string name, string surname, string dateOfBirth, string address)
{
FirstName = name;
SecondName = surname;
DateOfBirth = name;
Address = address;
}
public event EventHandler NewClient;
public virtual void OnNewClient(object sender, EventArgs e)
{
NewClient(this, e);
}
class Program
{
static void Main(string[] args)
{
Client client = new Client();
client.OnNewClient();
}
public void CreateNewClient( string name, string surname, string dateOfBirth, string address)
{
string Name = name;
string Surname = surname;
string Date = dateOfBirth;
string Address = address;
Client client = new Client(Name, Surname,Date, Address);
}
}