2013-03-07 101 views
1

这里后获得常数变量是我的C#类代码无法创建一个实例

public class ConstReadOnly 
{ 
    public const int cV = 10; 
    public readonly int rV = 40; 
} 

现在,当我尝试创建这个类我没有得到的const变量cV。什么可能是实例原因。

回答

0

因为常数implictly静态的。

如果您想使用它们,请使用类名称作为限定符。

int fromConstInt = ConstReadOnly.cV;