++1 是什么意思 [英] What does ++1 mean
问题描述
我刚刚看到有人发布了一些示例代码(here) 设置一个整数变量等于 ++1
.我很震惊 VB.NET 编译器会接受它作为有效的语法.例如,这编译:
I just saw some sample code that someone posted (here) that set an integer variable equal to ++1
. I was shocked that the VB.NET compiler would accept that as valid syntax. For instance, this compiles:
Dim i As Integer = 0
i = ++1
i = ++1
Console.WriteLine(i) ' Outputs "1"
据我所知,它似乎忽略了优点而只使用它后面的值.例如:
As best I can tell, it seems to ignore the pluses and just use the value that follows it. For instance:
Dim i As Integer = 0
i = ++10
Console.WriteLine(i) ' Outputs "10"
所以我的问题是,为什么这是有效的语法?+
运算符是否有一些我完全不知道的规则.据我所知,这是无效的,而且 ++
本身并不是 VB.NET 中的运算符.
So my question is, why is that valid syntax? Is there some rule for the +
operator that I'm totally unaware of. As far as I knew, that was invalid and ++
was not, itself, an operator in VB.NET.
推荐答案
与其他一些语言不同,它只是一个标志.符号可以复制——+-++1
有效,---3
有效,Not Not Not Not 条件
也有效.
Unlike in some other languages, it’s just a sign. Signs can be duplicated – +-++1
works, ---3
works, and Not Not Not Not condition
works as well.
这篇关于++1 是什么意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!