Using Linq:
public static string GetNextCode(string current)
{
string tmp = current.Length == 1 ? $"{current}0" : current;
char[] alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToArray();
char[] digit = "0123456789".ToArray();
var list = (from d in digit
from a in alpha
select $"{a}{d}")
.ToList();
int i = list.IndexOf(tmp) +1;
if(i>list.Count-1)
throw new Exception("Limit of codes has been reached!");
else
tmp = list[i];
return tmp.Substring(1,1).Equals("0") ? tmp.Substring(0,1) : tmp;
}
Usage:
void Main()
{
string currCode = "Z8";
string nextCode = GetNextCode(currCode);
Console.WriteLine($"{currCode} => {nextCode}");
}