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

  • Home
  • SEARCH
  • 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 213519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:17:10+00:00 2026-05-11T18:17:10+00:00

Exact Duplicate: In C# what is the difference between myint++ and ++myint? Hopefully this

  • 0

Exact Duplicate:

In C# what is the difference between myint++ and ++myint?

Hopefully this is not too general or weird of a question. Also, couldn’t find it on Google, don’t whether this is just too dumb of a question or whether I fail at Google.

So, I forget where I read this from but, it said that using ‘++x’ (or whatever other variable) is somehow more optimized or whatever you might call this than, ‘x++’.

So, is this just a looks thing or is one truly faster? Like, they do the exact same thing so, that is why I am asking.

  • 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-11T18:17:10+00:00Added an answer on May 11, 2026 at 6:17 pm

    They’re doing different things. The first is pre-increment, and the second is post-increment. If you use either alone on a line, you won’t notice the difference. But if you do (for instance):

    a = x++
    

    or

    a = ++x
    

    you will. With post-increment, you get the value, then increment. With pre-increment, you increment, then get the value. See http://en.wikipedia.org/wiki/++#Use_in_programming_languages for a brief explanation (they use JS as an example, but it applies equally to C#)

    EDIT: By popular demand (and to refute a couple exaggerations), here’s a little about performance with primitives in C++. Take this example program:

    int main()
    {
        int a;
        int x = 14, y = 19;
        a = x++;    
        a = ++y;    
    }
    

    It compiles (g++, just -S) to the below on x86. I have removed irrelevant lines. Let’s look at what’s happening and see if unnecessary duplicates are being made.:

            # Obvious initialization.
            movl    $14, -12(%ebp) 
            movl    $19, -16(%ebp)
    
            movl    -12(%ebp), %eax # This is moving "old x" to the accumulator.
            movl    %eax, -8(%ebp) # Moving accumulator to a.
            addl    $1, -12(%ebp) # Increment x (post-increment).
    
            addl    $1, -16(%ebp) # Increment y (pre-increment)
            movl    -16(%ebp), %eax # Move "new y" to accumulator.
            movl    %eax, -8(%ebp) # Move accumulator to a.
    

    We’re done.

    As you can see, in this example, the exact same operations are required in each case. Exactly 2 movl, and 1 addl. The only difference is the order (surprised?). I think this is fairly typical of examples where the increment statement’s value is used at all.

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

Sidebar

Related Questions

Duplicate of this question . update - This is not an exact duplicate. See
Closed as exact duplicate of this question . I have an array/list of elements.
Closed as exact duplicate of this question . But reopened, as the other Singleton
Exact Duplicate : Is there a performance difference between i++ and ++i in C++?
what is the difference between DLL and Assembly Exact duplicate : Difference Between Assembly
I know there is a seemingly exact duplicate of this question here: iPhone SDK:
Okay, this may be a dumb question, but I've not been able to find
Possible Duplicate: How does an interpreter/compiler work Hi what is the exact difference between
Closed as exact duplicate of How can I find the method that called the
This is an exact duplicate of: IE6 issues with transparent PNGs Firefox: IE 6:

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.