Tag: compile time

C#编译时字符串常量连接

C#是否对常量字符串连接进行任何编译时优化? 如果是这样,我的代码如何通过编写来利用这个? 示例:这些在运行时如何比较? Console.WriteLine(“ABC” + “DEF”); const string s1 = “ABC”; Console.WriteLine(s1 + “DEF”); const string s1 = “ABC”; const string s2 = s1 + “DEF”; Console.WriteLine(s2);