In the below code, I am defining an event handler and would like to access the age and name variable from that without declaring the name and age globally. Is there a way I
Yes, you could define the event handler as a lambda expression:
void Test(string name, string age) { Process myProcess = new Process(); myProcess.Exited += (sender, eventArgs) => { // name and age are accessible here!! eventHandled = true; Console.WriteLine("Process exited"); } }