Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Incrementing a string field
Message
From
19/12/2010 13:14:48
 
 
To
19/12/2010 10:15:54
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01493214
Message ID:
01493301
Views:
63
Aha!

Now that you've mentioned it Bonnie, I recall coming across that obscure fact while reading the Deitel book that you helped edit

At my age, factoids like that fade quickly.

Thanks again, Bonnie and Viv


>This works
>

> private void buttonCreatenewversion_Click(object sender, EventArgs e)
> {
> char c = Convert.ToChar(CurrentVersion);
> c++;
> string newversion = c.ToString();
>
> } // key down
>

>
>This gives me the existing version. Why is that??
>

> private void buttonCreatenewversion_Click(object sender, EventArgs e)
> {
> char c = Convert.ToChar(CurrentVersion);
> string newversion = c++.ToString();
>
> } // key down
>



It took me a few minutes to figure this one out, Bill, because at first I thought there was something wrong. However, it's not wrong, and here's why. The ++ operator, after the variable will execute last, before the variable will execute first. So, instead of c++, it will work if you use ++c, like so:
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform