c# - Can a switch statement be used on Control objects passed to an event handler? -
i have multiple controls share same event handler. instead of writing series of
if(sender == specific_control) { // } is there way use switch statement or similar instead?
when type switch(sender) error message says
a switch expression or case label must bool, char, string, intergral, enum, or corresponding nullable type.
if want event handler different depending on control raised event, why using same handler each control? give each control own handler method.
if there common code execute when handling of different events, put that single method can called various event handler methods.
if above advice not seem applicable scenario, please improve question it's clear why it's not. sure include a good, minimal, complete code example illustrates explanation.
Comments
Post a Comment