C#’+ =’运算符
我有一些包含运算符’+ =’的代码。
具体来说,代码如下:
foreach (KeyValuePair row in connectionOpts) { str += String.Format("{0}={1}; ", row.Key, row.Value); }
该操作员执行什么function?
它是一个赋值运算符。 它将右操作数添加到左操作数并将结果赋给左操作数。
您可能需要阅读一些教程 ,以便更好地理解c#基础知识。
它将两个字符串(或整数等)加在一起。
String a = "Hello"; a += " World";
String a now = "Hello World"
int i = 0; i += 2;
int我现在= 2