Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Incrementing a string field
Message
De
19/12/2010 13:14:48
 
 
À
19/12/2010 10:15:54
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01493214
Message ID:
01493301
Vues:
64
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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform