c#中有一句 interest+=","+i.tostring();是什么意思

2025-05-10 20:05:42
推荐回答(3个)
回答1:

interest是个字符串变量
interest+=","+i.tostring()就是等同于
interest=interest+","+i.tostring()
比如interest值是"abc",i的值是123,那这个语句让interest值变成了
abc,123
i.toString()是将i转换为字符串形式

回答2:

就是字符串拼接
比如一开始
interest值是“test”
i是5
interest+=","+i.tostring();
结果
interest值为 “test,5”

回答3:

首先interest应该是string类型
假设 interest=“AAA”,i=0,则
interest+=","+i.tostring();等价于 interest=interest+","+i.tostring();
运行后 interest=“AAA,0”