我在C#這樣的類:Overiding不斷
public class Foo
{
public static readonly int SIZE = 2;
private int[] array;
public Foo
{
array = new int[SIZE];
}
}
和Bar
類:
public class Bar : Foo
{
public static readonly int SIZE = 4;
}
我想accopmlish是創建數組的大小一欄實例從overrided SIZE
取值。如何正確地做到這一點?
您可以在構造函數中設置只讀參數,但可能不是靜態只讀,因爲它需要在不帶參數的靜態構造函數中設置。 – kenny 2012-04-22 11:04:40