Assuming there are buttons with all the letters from the alphabet set as Text.
I want to call a function in these buttons and use this letter as argument.
Can I use the same piece of code for each button in some way?
something like
functionname(this.Text);
Problem is, that “this” referrs to the Form and not to the specific button.
In most event mechanisms you can obtain the source of the event; in classic win forms vents this is typically called “sender”. You can cast the sender to what you know it is, or some common base-type. For example:
Hence with this a single event-handler can handle all the buttons.
This may vary subtly between infrastructure / tools (WCF, XNA etc) but fundamentally should remain similar.