Inheritence Accessing A Static Concrete Value
Is there a way to accomplish this using static members? I can get the correct behaviour using non static members and an abstract class but I dont want to instatiate the Foo class everytime I need to use the GetUpperName() method. Is this pattern just simply wrong? Is there a better/correct approach?
Code Snippet
public
classFooBase{
privatestaticstring name ="Should not see this."; publicstaticstring Name{
get {return name; } set { name =value; }}
publicstaticstring GetUpperName(){
return name.ToUpper();}
}
publicclassFoo :FooBase{
static Foo(){
Name =
"How can I use this string in the FooBase class?";}
}
[
TestFixture]publicclassFooTester{
[
Test] publicvoid TestUpperToolName(){
string expected ="HOW CAN I USE THIS STRING IN THE FOOBASE CLASS?"; string actual =Foo.GetUpperName(); Assert.AreEqual(expected,actual);}
}

