加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

VB.NET是否优化了字符串文字的连接?

发布时间:2020-12-17 00:28:49 所属栏目:大数据 来源:网络整理
导读:类似于 this的问题,但是对于VB.NET而言,自从我了解到这是一种语言的事情. 例如,编译器会知道要翻译 Dim s As String = “test ” + “this ” + “function” 至 Dim s As String = "test this function" 从而避免了字符串连接的性能? 是.它是.我只测试VS 2
类似于 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 
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读