类似于
this的问题,但是对于VB.NET而言,自从我了解到这是一种语言的事情.
例如,编译器会知道要翻译
Dim s As String = “test ” + “this ” +
“function”
至
Dim s As String = "test this function"
从而避免了字符串连接的性能?
是.它是.我只测试VS 2008,但我强烈怀疑以前的版本也是如此.
VB.NET
Public Class Class1 Dim s As String = "test " + "this " + "function" Public Function test() As String Return s End Function End Class
I.L. – 注意字符串“test this function”
{ .maxstack 8 L_0000: ldarg.0 L_0001: call instance void [mscorlib]System.Object::.ctor() L_0006: nop L_0007: ldarg.0 L_0008: ldstr "test this function" L_000d: stfld string ClassLibrary1.Class1::s L_0012: nop L_0013: ret }