相关疑难解决方法(0)

String.Format还是不?

重复来自:字符串输出:C#中的格式或concat?

特别是在使用String.Format的C#世界中,一切都很常见,通常作为VB.NET开发人员,除非我必须*我不是String.Format,

我更喜欢正常的字符串连接,例如:

V1 = V2 & "test-x" & V3 & "-;"
Run Code Online (Sandbox Code Playgroud)

对我而言,这比这更好:

V1 = String.Format("{0} test-x {1} -;", V2, V3)
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?或者这仅仅是个人偏好?

使用String.Format的原因(来自答案)(我会尽量保持最新)

  • 如果使用字符串格式,本地化会更容易
  • 显然,更改输入格式更容易
  • 它更具可读性(但这是个人的)
  • 更好的性能

**有时我需要动态更改样式或替换东西然后我使用String.Format*

.net format string.format coding-style

6
推荐指数
2
解决办法
2535
查看次数

标签 统计

.net ×1

coding-style ×1

format ×1

string.format ×1