Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 501523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:11:54+00:00 2026-05-13T06:11:54+00:00

I converted some c# code to vb.net and the converter.telerik.com turned this: i–; into

  • 0

I converted some c# code to vb.net and the converter.telerik.com turned this:

i--;

into this:

System.Math.Max(System.Threading.Interlocked.Decrement(i), i + 1)

Whats up with all the fancy-ness?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:11:54+00:00Added an answer on May 13, 2026 at 6:11 am

    Michał Piaskowski’s comment triggered the following explanation:

    The semantics of i-- in C# are to return the current value of i (i.e., the value before the decrement occurs) and then decrement i by one.

    So, we need to convert that to VB. We can not use i -= 1 because this does not return the current value of i before the decrement. So, we need an operation that will decrement i but return the value of i before the decrement, something like:

    Function DoPostDecrement(ByRef i As Integer) As Integer
        i -= 1
        Return i + 1
    End Function
    

    But this suggests using the following to avoid having to write a method to perform the above:

    System.Math.Max(
        someValueThatIsEqualToiMinusOne,
        someValueThatIsEqualtoiBeforeTheDecrement
    )
    

    But VB.NET won’t let you use i -= 1 or i = i - 1 in place of someValueThatIsEqualToiMinusOne. However, System.Threading.Interlocked.Decrement(i) is legit and equal to the value of i - 1. Once you do that, because parameters are evaluated left to right, someValueThatIsEqualtoiBeforeTheDecrement should be i + 1 (at that point the decrement has been performed to i + 1 is the pre-decrement value.

    Note that the above method DoPostDecrement and the System.Math.Max, System.Threading.Interlocked.Decrement construct could have different semantics in a multithreaded context.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all, i have converted some C# PayPal API Code over to VB.net. I
I'm a C# programmer but am converting some code from C# to VB.NET. In
I'm trying to convert some code that worked great in VB, but I can't
I'm a relatively new convert to Python. I've written some code to grab/graph data
I have some c(++) code that uses sprintf to convert a uint_64 to a
I'm working with some example java code for making md5 hashes. One part converts
I'm trying to convert some Xaml to HTML using the .NET XslCompiledTransform and am
How can I convert some Geometry data into Geography data in MS SQL Server
We recently came across some sample code from a vendor for hashing a secret
I'm having a problem with some code I've written. I've had to anonymize it,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.