Really trivial I suppose, but I don't understand what index++ does. How would this be written in VB.net?
int index = 0;
foreach(String prop in props.Keys)
{
pSpec.pathSet[index++] = prop;
}
pSpecs.Add(pSpec);
It's just a post-increment. Meaning it will return it's value and then increase it's value by 1.
pSpec.pathSet[index++] = prop;
in VB.net would most likely be just:
pSpec.pathSet[index] = prop
index = index + 1 // this would work
index += 1 // this would work too
It's just important to note that you can't do it inline that way (as you'll need the previous value).
The increment operator (++)
increments its operand by 1. The increment operator can appear before or after its operand:
It's is the same index = index +1;
Dim index As Integer = 0
For Each prop As [String] In props.Keys
index = index +1
pSpec.pathSet(index) = prop
Next
pSpecs.Add(pSpec)
well you will have to increment it in this fashion
index =index + 1;
or index +=1
If interested why no increment operator
Got this using this
Dim index As Integer = 0
For Each prop As [String] In props.Keys
pSpec.pathSet(System.Math.Max(System.Threading.Interlocked.Increment(index),index - 1)) = prop
Next
pSpecs.Add(pSpec)
index++ will increment index by 1.
I don't know much VB but you could do:
index = index + 1
index++
returns the current value of index
and after that, it increments the value of index
.
In the first iteration, it will return 0 as value, and after it the value will be increased to 1. In the second iteration, it will return 1 as value, and after it the value will be increased to 2.
The '++' operator doesn't exist in VB, you have to increment it yourself.
Is this what you are looking for
Dim index As Integer = 0
For Each prop As [String] In props.Keys
pSpec.pathSet(System.Math.Max(System.Threading.Interlocked.Increment(index),index - 1)) = prop
Next
pSpecs.Add(pSpec)
index++ increments the value of index by 1. That syntax is not available in VB.NET (http://www.knowdotnet.com/articles/paulvick.html)
so index++ is the equivalent of index = index+1 your vb code should be something like:
{
index = index+1
pSpec.pathSet[index] = prop
}
As mentioned this just increments the value.
++ is not a valid operator in VB.NET but the closest thing is probably:
index += 1
This was a nice change for anyone coming from VB6 because before we had to always use the longhand index = index + 1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.