Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Incrementing a string field
Message
De
18/12/2010 10:53:08
 
 
À
18/12/2010 10:13:59
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01493214
Message ID:
01493217
Vues:
58
>I'm converting a VFP app that produces versions that start with "A" and proceed upward.
>So, if the latest version is "C", the next version is "D", etc.
>Developing the next version letter was easy in VFP, but all the answers I'm finding for C# seems needlessly cumbersome.
>
>What is the simplest way to put the next version letter in string NextVersion when the current version is in string CurrentVersion?

You don't give much detail on the actual structure of the string. Maybe something like:
string CurrentVersion  = "123D456";
 
 // One way
char[] c = CurrentVersion.ToCharArray();
c[3]++;
string NextVersion = new string(c);

 //Another way
char x = CurrentVersion[3];
NextVersion = CurrentVersion.Replace(x, ++x);
but what should happen when you get to 'Z' ?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform