c# - Explain this: CheckBox checkbox = (CheckBox)sender; -


while going through checkbox found there written

checkbox checkbox = (checkbox)sender 

on checkbox1_checkedchanged event.

please explain means?

the line casts sender checkbox.

why?

the event handler signature checkedchanged event is:

checkchanged(object sender, eventargs e) 

so, need cast sender checkbox if want use checkbox specific functionality - object doesn't have can use...

this way checkbox variable can used checkbox id , operate on checkbox.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -