i think what you're trying to do is something like:
switch(sender){
case (btn1):
...
break;
case (btn2):
...
break;
case (btn3):
...
break;
}
----- Original Message -----
From: "Mike Andrews" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, June 20, 2006 4:54 PM
Subject: [ADVANCED-DOTNET] VB's Select Case Equivalent in C#
Guys,
Does anyone know if something like this is possible in C#:
private void ButtonClick(object sender, EventArgs e) {
switch(true){
case (sender == btn1):
...
break;
case (sender == btn2):
...
break;
case (sender == btn3):
...
break;
}
I've looked at sample code and read up on the switch statement and it
appears to be unavailable.
Why is that? If C# is modern language, why does it not have some very
simple abilities that VB has had?
It seems that if you want to have one procedure handle the click events
for
several buttons, that doing it this way is harder to read:
...
if (sender == btn1){
...
}else if (sender == btn2){
...
}else if (sender == btn3){
...
}
...
Thanks,
Mike
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at
http://discuss.develop.com
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com