腾讯云的域名需要怎么转出?具体转出流程是什么?
从性能和代码生成的角度来看,确实没有什么区别。在性能测试中,他们之间来回跳动,其中一个比另一个快,而且只有毫秒。
在看后面的代码,你真的没有看到任何区别。唯一的区别是在IL中,它string.Empty使用操作码ldsfld 并""使用操作码ldstr,但这只是因为string.Empty是静态的,并且两个指令都做同样的事情。如果您查看生产的组件,则完全相同。
C#代码
private void Test1()
{
string test1 = string.Empty;
string test11 = test1;
}
private void Test2()
{
string test2 = "";
string test22 = test2;
}
IL代码
.method private hidebysig instance void
Test1() cil managed
{
// Code size 10 (0xa)
.maxstack 1
.locals init ([0] string test1,
[1] string test11)
IL_0000: nop
IL_0001: ldsfld string [mscorlib]System.String::Empty
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: stloc.1
IL_0009: ret
} // end of method Form1::Test1
.method private hidebysig instance void
Test2() cil managed
{
// Code size 10 (0xa)
.maxstack 1
.locals init ([0] string test2,
[1] string test22)
IL_0000: nop
IL_0001: ldstr ""
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: stloc.1
IL_0009: ret
} // end of method Form1::Test2
汇编代码
string test1 = string.Empty;
0000003a mov eax,dword ptr ds:[022A102Ch]
0000003f mov dword ptr [ebp-40h],eax
string test11 = test1;
00000042 mov eax,dword ptr [ebp-40h]
00000045 mov dword ptr [ebp-44h],eax
string test2 = "";
0000003a mov eax,dword ptr ds:[022A202Ch]
00000040 mov dword ptr [ebp-40h],eax
string test22 = test2;
00000043 mov eax,dword ptr [ebp-40h]
00000046 mov dword ptr [ebp-44h],eax
其他人建议每次使用时都会创建一个新的字符串""。这是不正确的 - 由于字符串interning,它会创建一个程序集或每个AppDomain一次(或可能一次为整个过程 - 不知道在这方面)。这种差异可以忽略不计-大规模,大量微不足道。
然而,你发现更可读的是另一回事。这是主观的,会因人而异 - 所以我建议你找出你的团队中大多数人都喜欢的东西,并且为了保持一致,我个人觉得""更容易阅读。
该参数""和" "很容易误认为对方并没有真正和我一起洗。除非你使用比例字体(而且我还没有和任何开发人员一起工作),否则很容易区分。