【发布时间】:2018-06-30 22:45:31
【问题描述】:
鉴于下面的代码,我想知道为什么referenceValue = ConstantInt; 有效而referenceValue = StaticInt; 无法编译。
namespace Demo
{
public class Class1
{
private const int ConstantInt = 42;
private static readonly int StaticInt = 42;
public void DemoMethod(ref uint referenceValue)
{
referenceValue = ConstantInt; // This compiles
referenceValue = StaticInt; // This claims that the source type 'int' cannot be converted to 'unit' implicitly.
}
}
}
【问题讨论】: