Categorized | C# FAQ

Post Incrementation and Pre Incrementation

See the below example to understand the difference between post incrementation and pre incrementation.

int

 

x = 10;int z;//First assigns value of x (10) to z and then x value incremented to 11.

z=x++;MessageBox.Show(“Post Incement of x=” + z);int y = 20;int a;

//First increments value of y to (21) and assigns 21 to as.a=++y; 

MessageBox.Show(“Pre incrementor Y=”+a);

EasyFreeAds Blog News Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google Yahoo Buzz StumbleUpon

7 Responses to “Post Incrementation and Pre Incrementation”

  1. subhashini says:

    I have a small doubt on return types.suppose if we want to return two values i.e int and string from same method.what is the solution for this.

  2. satish says:

    I don’t think one can return more than one value from a function or any thing. But one can achieve it through returning a structure. Or same can be achieved by call by ref and update their values.

  3. Techpalle says:

    You can always return an object or object array which contains more than one value.
    For Best Android Training Click Android Training in Bangalore

  4. Ya, in that way one can return.

  5. shibsankar says:

    hi,
    i want to know that how can i get system update date time? except system.DateTime.now; because it is giving only current time, but not updating.

  6. shibsankar says:

    hi,
    i want to know that “can i write more than one main method in a single program in c#(console application)?”.

  7. When ever you refresh Page the time will be automatically updated by the server side C# code.
    To get update of the time automatically in your Client( Browser every second then you need to use
    JavaScript date time methods.)

Trackbacks/Pingbacks


Leave a Reply