2
Answers

asp.net server control reference

Al

Al

4y
692
1

Hi,

 I am familiar with this piece of code:

LinkButton myLb = (LinkButton)sender;
string cmd2 = myLb.CommandName;
 
However I came across this new code to me , but it does the same thing as the upper code. 

                string cmd = (sender as LinkButton).CommandName;

my question, is this a way of casting. How do I know when to use this kind of conversion.
 
Thanks
 
Al
Answers (2)