gpt4 book ai didi

asp.net - 使用 & 符号的简单 VB

转载 作者:行者123 更新时间:2023-12-02 06:26:38 24 4
gpt4 key购买 nike

快点,我确定......

我正在查看前雇员编写的一些代码,并不断看到“&”号后跟一个等号,即 &=

我根本没有使用过这个,并且想知道为什么要使用它而不是仅使用&符号。

最佳答案

& 是连接运算符。

在表达式中使用 &= 时,例如:

string1 &= string2

这与:

相同
string1 = string1 & string2

operator= 的使用在 C、C#、C++、Java 等语言中非常常见 - 它们具有 -=+= 等结构 等等,这只是意味着左操作数中的变量将用于二元运算,并将结果赋回该变量。

MSDN 是这样描述的 - &= Operator (Visual Basic) :

Concatenates a String expression to a String variable or property and assigns the result to the variable or property.

关于asp.net - 使用 & 符号的简单 VB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7920648/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com