例如我有一个
String a="Hello";
a+="World";
这会将 World 放在最后。怎么放在开头呢?
最佳答案
简单地:
string a = "Hello";
a = "World" + a;
最终,a += "World";
只是以下语法的缩写:
a = a + "World";
如果要颠倒操作数的顺序,则不存在这样的缩写。
作为旁注 - 请记住,如果您经常这样做(在循环中等),最好考虑使用 StringBuilder
来避免很多中间 string
s.
关于c# - += 使用字符串的相反操作是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16542044/