C# 6 nameof 是否在构建过程中得到优化?
Does the C# 6 nameof get optimized out during build?
例如,如果您有类似
class SomeClass
{
public string SomeFieldName => nameof(SomeField);
public int SomeField = 3;
}
nameof() 调用是否会被字符串 nameof() 替换 return?在这种情况下,"SomeField".
是的。 nameof
是一种语言功能,而不是 CLR 功能。它编译成一个字符串常量。
例如,如果您有类似
class SomeClass
{
public string SomeFieldName => nameof(SomeField);
public int SomeField = 3;
}
nameof() 调用是否会被字符串 nameof() 替换 return?在这种情况下,"SomeField".
是的。 nameof
是一种语言功能,而不是 CLR 功能。它编译成一个字符串常量。