很困惑'+=' C# 中的运算符
我们正在讨论在编码课上看到的一些事情。据我们所知,讲师使用 += 和 C# 以某种方式实例化/创建了一个变量。
我知道它不是处理订阅事件或将 y 添加到 x,但不知道是否有人可以阐明我们可能看到的内容?
We were discussing something we saw in a coding class. From what we recall, the instructor instantiated/created a variable somehow using += and C#.
I know it wasn't dealing with subscribing to events or adding y to x but didn't know if anyone out there could shed some light on what we might have seen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
+=
运算符对于许多类型都是重载的(以及为内置类型定义的)。确实,仅从您的简介中很难判断他用它来做什么。添加到现有整数:
连接字符串:
订阅事件
所以基本上,简而言之,它只是将当前值添加到现有值。没有更多信息,无法更具体...
The
+=
operator is overloaded for many types (as well as defined for built in types). Really it's hard to tell just from your blurb what he was using it to do.Add to existing integer:
Concatenate a string:
Subsribe to an event
So basically, in a nutshell, it just adds the current value to the existing one. Without more information, can't be more specific...
也许你看到过这样的事情
May be you saw something like this