1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
static string IncreaseString(string value, string chars)
{
if (string.IsNullOrEmpty(value))
throw new ArgumentException("value can't be null or empty.", "value");
else if (string.IsNullOrEmpty(chars))
throw new ArgumentException("chars can't be null or empty.", "chars");
char[] result = value.ToCharArray();
for (int i = result.Length - 1; i >= 0; i--)
{
int index = chars.IndexOf(result[i]);
if (index == -1)
throw new ArgumentException("Invalid Char " + result[i], "value");
if (index < chars.Length - 1)
{
result[i] = chars[index + 1];
break;
}
else
{
result[i] = chars[0];
}
}
return new string(result);
}
|