vb.net - 在函数中用连字符连接字符串
问题描述
我试图在我的函数中硬编码一个连字符并返回字符串,但我无法构建语法。你们能帮我语法吗?
NES_Person_ComputeInternalName_Internal(GetValue("FirstName").String, GetValue("LastName").String, _
Getvalue(uid_dialogcountry_iso3456).string,GetValue("City").String, _dep, GetValue("personnelNumber").String )
我想要之间的连字符:
Getvalue(uid_dialogcountry_iso3456).string, GetValue("City").String
解决方案
假设NES_Person_ComputeInternalName_Internal
简单地连接您的字符串(这可能是不正确的),您可以使用字符串插值以获得更好的可读性(以及一段略短的代码):
Dim myString As String = $"{GetValue("FirstName").String}{GetValue("LastName").String}{GetValue(uid_dialogcountry_iso3456).String}-{GetValue("City").String}{_dep}{GetValue("personnelNumber").String})
根据GetValue
的行为,您甚至可以省略.String
:
Dim myString As String = $"{GetValue("FirstName")}{GetValue("LastName")}{GetValue(uid_dialogcountry_iso3456)}-{GetValue("City")}{_dep}{GetValue("personnelNumber")})
字符串插值很棒,因为它会为您插入插入变量的类型。但是,您无需对此表单进行任何格式化,因此如果需要,您需要包含.ToString({StandardOrPredefinedStringFormat})
.
推荐阅读
- c# - 尝试获取进程开始时间时“访问被拒绝”
- java - 开关中有两个完全相同的 startactivity(),只有一个有效
- c++ - 为什么 int 在函数中不需要是常量和/或通过引用传递?
- dynamic - Flutter - 动态创建表
- jsp - 在 JSP 上显示文件内容
- tizen-web-app - 在工作区中找不到安装许可的证书配置文件
- c++ - 这种 QChangesOpacityEffect 用法会导致潜在的内存泄漏吗?(但只有强制重绘的方法......)
- ruby-on-rails - Rspec 用于相互依赖并使用 gem 的模型方法
- javascript - .eq(i) i 未定义但有效吗?
- ruby - Rails API - 本地文件未上传到 s3/Heroku