title: Can I override variables declared in a class using VB.NET?
body: <p>I'm trying to create a generic Controller Class for generic events. But these these events still need to access their class variable. So my idea is to create the Base Controller Class with a ModelBaseclass variable as _ClassVar, which is inherited by all of the other class Controller classes will derive from. But I want the derived controller classes to override the _ClassVar with whichever one they need.</p>
  
  <p>I want to do this, so the ControllerBaseClass can have all the generic functions that all the Derived Classes would use.</p>
  
  <p>Model :</p>
  
  <pre><code>Public Class ModelBaseClass
      Public Overridable Function Foo() As String
          Return "Name"
      End Function
  End Class
  
  Public Class ModelDerivedClass1
      Inherits ModelBaseClass
      Public Overrides Function Foo() As String
          Return "ModelDerivedClass1"
      End Function
  End Class
  
  Public Class ModelDerivedClass2
      Inherits ModelBaseClass
      Public Overrides Function Foo() As String
          Return "ModelDerivedClass2"
      End Function
  End Class
  </code></pre>
  
  <hr>
  
  <p>Controller :</p>
  
  <pre><code>Public Class ControllerBase
             Public Overridable _ClassVar As ModelBaseClass       &lt;----
      Public Function PrintFoo() As String                        
          Return _ClassVar.Foo()
      End Function
  End Class
  
  Public Class ControllerDerivedClass1
      Inherits ControllerBase
           Public Overrides _ClassVar As ModelDerivedClass1       &lt;---- 
  End Class
  
  Public Class ControllerDerivedClass2
      Inherits ControllerBase
           Public Overrides _ClassVar As ModelDerivedClass2       &lt;----  
  End Class
  </code></pre>