In some obscure way, a derived class that does not add new functionality (for now) behaves different from the base class. Derived class:
public class MyCheckButton : CheckButton { public MyCheckButton(string label) : base(label) { } }
MyCheckButton inherits from (GTK #, part of the Mono project) CheckButton. However, in the following code snippet, they behave differently:
var button1 = new CheckButton("_foo"); var button2 = new MyCheckButton("_foo");
An underscore on a label ensures that the label becomes mnemonic. For button1, this works in my test code: I get "foo" where f is underlined. However, for button 2, this fails. I just get "_foo" as a label in my dialog box.
Can someone explain how the derived class in this example can behave differently or is there some kind of magic coming up behind the screen that might check the type of the actual class?
Maurits Rijk
source share