|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VB equivalent of this C# codei ++ in VB is i += 1 or i = i + 1
-- Show quoteHide quoteDavid Anton www.tangiblesoftwaresolutions.com Instant C#: VB to C# converter Instant VB: C# to VB converter Instant C++: C#/VB to C++ converter Instant Python: VB to Python converter "Jon Paal" wrote: > what is vb equiv. of > > ++ > > shown in C# ? > > > "Jon Paal" <Jon[ nospam ]Paal @ everywhere dot com> wrote in message David's answer is correct, but with the ++ (increment) and -- (decrement) news:efMxQfX8GHA.1252@TK2MSFTNGP04.phx.gbl... > what is vb equiv. of > > ++ > > shown in C# ? operators, you also need to be aware that the ++ and -- operators each come in two versions, prefix and postfix, that affect operation in complex expressions. int i = 5; i++; and ++i; do exactly the same thing, add 1 to the current value in the variable i. i--; and --i; also do exactly the same thing, subtract 1 from the current value in i. So, prefix vs. postfix notation makes no difference in simple expressions. In an expression like this, however, Assume i == 5 if (i++ > 5) vs. if(++1 > 5). there is a difference: if(i++ > 5) evaluates the Boolean expression based on the *current* value in i, then adds 1 to i. The Boolean expression is false. if(++1 > 5) *first* adds 1 to i, then evaluates the Boolean expression using the new value in i. The Boolean expression is true. As you didn't show the context in which you encountered the ++ in C# code, I though you should be aware of the difference between prefix and postfix notation. So when you take it all into consideration, there is no single statement
equivalent to statements containing ++ or --, since VB doesn't allow assignments within expressions (there is a complex multi-statement equivalent however). There is only a single statement equivalent for simple "i++" or "i--" statements. -- Show quoteHide quoteDavid Anton www.tangiblesoftwaresolutions.com Instant C#: VB to C# converter Instant VB: C# to VB converter Instant C++: C#/VB to C++ converter Instant Python: VB to Python converter "pvdg42" wrote: > > "Jon Paal" <Jon[ nospam ]Paal @ everywhere dot com> wrote in message > news:efMxQfX8GHA.1252@TK2MSFTNGP04.phx.gbl... > > what is vb equiv. of > > > > ++ > > > > shown in C# ? > David's answer is correct, but with the ++ (increment) and -- (decrement) > operators, you also need to be aware that the ++ and -- operators each come > in two versions, prefix and postfix, that affect operation in complex > expressions. > > int i = 5; > i++; and > ++i; do exactly the same thing, add 1 to the current value in the variable > i. > > i--; and > --i; also do exactly the same thing, subtract 1 from the current value in i. > > So, prefix vs. postfix notation makes no difference in simple expressions. > > In an expression like this, however, > > Assume i == 5 > if (i++ > 5) vs. if(++1 > 5). > > there is a difference: > if(i++ > 5) evaluates the Boolean expression based on the *current* value in > i, then adds 1 to i. > The Boolean expression is false. > > if(++1 > 5) *first* adds 1 to i, then evaluates the Boolean expression using > the new value in i. > The Boolean expression is true. > > As you didn't show the context in which you encountered the ++ in C# code, I > though you should be aware of the difference between prefix and postfix > notation. > > > David Anton wrote:
> So when you take it all into consideration, there is no single statement Well, if you *really*, *really* want it, nothing but common sense> equivalent to statements containing ++ or --, since VB doesn't allow > assignments within expressions (there is a complex multi-statement equivalent > however). There is only a single statement equivalent for simple "i++" or > "i--" statements. forbids you from having: <air-code> Function PreInc(ByRef Value As Integer) As Integer Value +=1 Return Value End Function Function PostInc(ByRef Value As Integer) As Integer Dim Result As Integer = Value Value +=1 Return Result End Function Function PreDec(ByRef Value As Integer) As Integer Value -=1 Return Value End Function Function PostDec(ByRef Value As Integer) As Integer Dim Result As Integer = Value Value -=1 Return Result End Function </air-code> Regards, Branco. c#code :
if (failureCount++ >= MaxInvalidPasswordAttempts) {... source of c# is example here: http://www.eggheadcafe.com/articles/20051119.asp Jon,
I know it only on one place and that is in a "for index". step 1 Cor Show quoteHide quote "Jon Paal" <Jon[ nospam ]Paal @ everywhere dot com> schreef in bericht news:efMxQfX8GHA.1252@TK2MSFTNGP04.phx.gbl... > what is vb equiv. of > > ++ > > shown in C# ? >
Performance of Queue(of T).Enqueue(T)
How to convert a Byte() to an IntPtr in VB Regex.Split... Can I do this?? control array with code added controls Why no patch for the anoying Visual Basic compiler problem Pause and Stop Search Help System .chm linking problem how to make string containing " ? Not CLS-compliant warning... Help understanding user created Delegates |
|||||||||||||||||||||||