对于以下代码,我想知道为什么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.
}
}
}