Anibal wrote:
How do i convert an object variable to a Button one.
I have the following code in VB wich works fine:
Sub Button1Click(sender As Object, e As System.EventArgs)
Dim btn as Button = Convert.ChangeType(sender,GetType(Button))
MessageBox.Show(btn.Text)
End Sub
How can i reproduce the same behaivour in C#?
Thanks.
I don't know VB well but I think casting is what you want.
public void Button1Click(Object sender, EventArgs e) {
Button btn = (Button) sender; // casting from Object to Button.
MessageBox.Show(btn.Text);
}
I'm hopped up on cough medicine, so I may be inaccurate here, but I
think this is what you're trying to do.
jeremiah