开发者

Using two equals signs in Visual Basic 2008

In code, why wouldn't this work?

开发者_开发百科
intMax = intTopValue = 20


This is interpreted as intMax = (intTopValue = 20).

intTopValue = 20 will check whether intTopValue is equal to 20 and return true or false.
This boolean will then be assigned to intMax.

Most languages don't have this issue, since they use separate operators for assignment (= or :=) and equality (== or =).

By contrast, VB shares = for both operations. Therefore, when a = b is written as an expression, it always means equality.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜