public class SomeBase {}
public class SomeObjectA : SomeBase {}
public class SomeObjectB : SomeBase {}
public class Test
{
public static bool someBool = true;
public static SomeBase someBaseField = GetBase(someBool);
public static SomeBase someBaseProperty { get { return GetBase(someBool); } }
public static SomeBase GetBase(bool getA)
{
if(getA)
return new SomeObjectA() as SomeBase;
else
return new SomeObjectB() as SomeBase;
}
}