As far as i know that will not work in C#. You can either use a field or create a variable in the property/method. In VB.NET you have the Static keyword for local variables(see below).
You have commented that you have many derived classes and you don't want to have a static field array for each derived class. I would suggest to use a different approach then. You could f.e. use a static Dictionary in your base class and an enum for each derived class:
abstract class Base
{
public abstract DerivedType Type { get; }
protected static readonly Dictionary<DerivedType, int[]> SomeDict;
static Base()
{
SomeDict = new Dictionary<DerivedType, int[]>();
SomeDict.Add(DerivedType.Type1, new int[] { 1, 2, 3, 4 });
SomeDict.Add(DerivedType.Type2, new int[] { 4, 3, 2, 1 });
SomeDict.Add(DerivedType.Type3, new int[] { 5, 6, 7 });
// ...
}
public static int[] SomeArray(DerivedType type)
{
return SomeDict[type];
}
}
public enum DerivedType
{
Type1, Type2, Type3, Type4, Type5
}
class Derived : Base
{
public override DerivedType Type
{
get { return DerivedType.Type1; }
}
}
In VB.NET, however, it is possible using a static local variable using the Static-keyword:
MustInherit Class Base
Public MustOverride ReadOnly Property someArray() As Integer()
End Class
Class Derived
Inherits Base
Public Overrides ReadOnly Property someArray() As Integer()
Get
Static _someArray As Int32() = New Integer() {1, 2, 3, 4}
Return _someArray
End Get
End Property
End Class
_someArray will be the same for every instance of Derived.
Deriveds from oneBase, and they all have a class-wide array. To be precise: the array holds a list of supported features which can vary perDerived.