Click here to Skip to main content
15,918,596 members
Home / Discussions / C#
   

C#

 
GeneralRe: Accessing vairable etc in a different class Pin
monrobot139-Mar-03 11:31
monrobot139-Mar-03 11:31 
GeneralRe: Accessing vairable etc in a different class Pin
jpwkeeper10-Mar-03 1:59
jpwkeeper10-Mar-03 1:59 
GeneralRe: Accessing vairable etc in a different class Pin
monrobot1310-Mar-03 15:42
monrobot1310-Mar-03 15:42 
GeneralRe: Accessing vairable etc in a different class Pin
jpwkeeper11-Mar-03 3:40
jpwkeeper11-Mar-03 3:40 
GeneralInherited Static Constructors Pin
moredip8-Mar-03 9:51
moredip8-Mar-03 9:51 
GeneralRe: Inherited Static Constructors Pin
Nnamdi Onyeyiri8-Mar-03 10:45
Nnamdi Onyeyiri8-Mar-03 10:45 
GeneralRe: Inherited Static Constructors Pin
moredip8-Mar-03 11:49
moredip8-Mar-03 11:49 
GeneralRe: Inherited Static Constructors Pin
leppie8-Mar-03 12:01
leppie8-Mar-03 12:01 
moredip wrote:
So it seems that inheritance polymorphism isn't available for the static members of a class. Is this intentional, and is there an elegant way around this?

I think its more to do with bad design Unsure | :~

What you are infact doing is just calling the same static function pointing to the baseclass. Remember with static constructors, the base constructor is not called, hence the fact that classname never gets changed.

Do something like this rather:
<code><font  size=2 face="Courier New"><font color="#FFFFFF">   </font><font color="#0000FF">class </font><font color="#000000">Parent
   </font>{
      <font color="#000000">internal </font><font color="#0000FF">static </font><font color="#000000">string className</font>;
      <font color="#0000FF">static </font><font color="#000000">Parent</font>()
      {
         <font color="#000000">className </font>= <font color="#FF8000">"Parent"</font>;
      }
      <font color="#0000FF">static public void </font><font color="#000000">OutputClassName</font>()
      {
         <font color="#000000">System</font>.<font color="#000000">Console</font>.<font color="#000000">Out</font>.<font color="#000000">WriteLine</font>( <font color="#000000">className </font>);
      }
   }
   <font color="#0000FF">class </font><font color="#000000">ChildA </font>: <font color="#000000">Parent
   </font>{
      <font color="#0000FF">static </font><font color="#000000">ChildA</font>()     
      {
         <font color="#000000">Parent</font>.<font color="#000000">className </font>= <font color="#FF8000">"ChildA"</font>;
      }
   }
   <font color="#0000FF">class </font><font color="#000000">ChildB </font>: <font color="#000000">Parent
   </font>{
      <font color="#0000FF">static </font><font color="#000000">ChildB</font>()     
      {
         <font color="#000000">Parent</font>.<font color="#000000">className </font>= <font color="#FF8000">"ChildB"</font>;
      }
   }
</font>
</code>


I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
GeneralRe: Inherited Static Constructors Pin
moredip8-Mar-03 12:14
moredip8-Mar-03 12:14 
GeneralRe: Inherited Static Constructors Pin
leppie8-Mar-03 12:44
leppie8-Mar-03 12:44 
GeneralRe: Inherited Static Constructors Pin
moredip8-Mar-03 12:56
moredip8-Mar-03 12:56 
GeneralRe: Inherited Static Constructors Pin
leppie8-Mar-03 13:14
leppie8-Mar-03 13:14 
GeneralRe: Inherited Static Constructors Pin
moredip8-Mar-03 13:43
moredip8-Mar-03 13:43 
GeneralRe: Inherited Static Constructors Pin
moredip8-Mar-03 13:53
moredip8-Mar-03 13:53 
GeneralRe: Inherited Static Constructors Pin
moredip8-Mar-03 14:10
moredip8-Mar-03 14:10 
GeneralRe: Inherited Static Constructors Pin
leppie8-Mar-03 14:25
leppie8-Mar-03 14:25 
GeneralRe: Inherited Static Constructors Pin
moredip8-Mar-03 16:05
moredip8-Mar-03 16:05 
GeneralRe: Inherited Static Constructors Pin
leppie9-Mar-03 7:02
leppie9-Mar-03 7:02 
GeneralRe: Inherited Static Constructors Pin
moredip9-Mar-03 7:26
moredip9-Mar-03 7:26 
GeneralRe: Inherited Static Constructors Pin
leppie9-Mar-03 7:54
leppie9-Mar-03 7:54 
GeneralTextBox DataBinding Pin
leppie8-Mar-03 7:24
leppie8-Mar-03 7:24 
GeneralRe: TextBox DataBinding Pin
leppie8-Mar-03 7:31
leppie8-Mar-03 7:31 
GeneralDocking Problem Pin
Mazdak8-Mar-03 7:02
Mazdak8-Mar-03 7:02 
GeneralRe: Docking Problem Pin
leppie8-Mar-03 7:19
leppie8-Mar-03 7:19 
GeneralRe: Docking Problem Pin
Mazdak8-Mar-03 8:15
Mazdak8-Mar-03 8:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.