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

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

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