In VB.NET you can access a base class via the MyBase keyword, and in C# it is via base keyword.
My question is, does anyone know why C# is designed in such a way that you can only access this base class variable inside a method. In VB it is within scope anywhere in the class (other than shared methods).
Code:'this works Public Class ExtendedTextbox Inherits System.Windows.Forms.TextBox Private _backColor As Color = MyBase.BackColor End Class //this doesn't class ExtendedTextbox : System.Windows.Forms.TextBox { private Color _backColor = base.BackColor; //ERROR ON THIS LINE }




Reply With Quote