I am browsing C # (C ++ background) and I came to this piece of code:
public interface IUndoable { void Undo(); }
public class TextBox : IUndoable
{
void IUndoable.Undo() { Console.WriteLine ("TextBox.Undo"); }
}
public class RichTextBox : TextBox, IUndoable
{
public new void Undo() { Console.WriteLine ("RichTextBox.Undo"); }
}
Since a RichTextBox comes from a TextBox, can anyone explain why a RichTextBox also comes from IUndoable ?. I would have thought that the IUndoable interface would be “inherited” along with any other TextBox members that RichTextBox has access to?
As an aside, I guess from what I have read so far that the concept of open, protected, and private inheritance does not exist in C #.
Is this the right conclusion ?. If so, how will this behavior (i.e., inheritance restriction) be implemented in C #?
[change]
: , , - . , ( ) , , , (phew!).
:
:
public class RichTextBox : TextBox, IUndoable
{
public new void Undo() { Console.WriteLine ("RichTextBox.Undo"); }
}
:
public class RichTextBox : TextBox
{
public new void Undo() { Console.WriteLine ("RichTextBox.Undo"); }
}
, ( , ).
, TextBox?