public string GetNewCode( string strOldCode)
{
const string cNumbers = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
if (strOldCode == null || strOldCode == string . Empty) return strOldCode;
char [] vChars = strOldCode . ToCharArray();
for ( int i = vChars . Length - 1 ; i >= 0 ; i -- )
{
int p = cNumbers . IndexOf(vChars[i]);
if (p < 0 ) return null ; // error
if (p + 1 <= cNumbers . Length - 1 )
{
vChars[i] = cNumbers[p + 1 ];
for ( int j = vChars . Length - 1 ; j > i; j -- )
vChars[j] = cNumbers[ 0 ];
break ;
}
}
return new string (vChars);
}
private void button1_Click( object sender , EventArgs e)
{
string s = "00" ;
for ( int i = 0 ; i < 100 ; i ++ )
{
s = GetNewCode(s);
Console . WriteLine(s);
}
}