Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Incrementing a string field
Message
From
18/12/2010 10:53:08
 
 
To
18/12/2010 10:13:59
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01493214
Message ID:
01493217
Views:
57
>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' ?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform