Get next string replace by suffix value by Alphabet

//This function returns next suffix value by alphabet
//for example Strvalue=123A then it gives 123B...... 123Z etc.
// call this function like
// StrSuffix=GetNextSuffix("123A");



public string GetNextSuffix(string Strvalue)
{

char[] temp =new char [1];
if (Strvalue.Length > 0)
{
string t = Strvalue.Substring(Strvalue.Length - 1, 1);
int iAsciiValue;
temp[0] = Convert.ToChar(t);
iAsciiValue = Convert.ToInt32(((int)temp[0]).ToString());
if (iAsciiValue >= Convert.ToInt32(((int)'A').ToString()) && iAsciiValue <= Convert.ToInt32(((int)'Z').ToString()))
{
if (iAsciiValue == Convert.ToInt32(((int)'Z').ToString()))
{
// Strvalue = Strvalue.Replace("Z","A");
iAsciiValue = Convert.ToInt32(((int)'A').ToString());
char[] suffix = new char[1];
suffix[0] = Convert.ToChar(iAsciiValue);
Strvalue = Strvalue.PadRight(Strvalue.Length + 1, suffix[0]);
}
else
{
iAsciiValue = iAsciiValue + 1;
char[] suffix = new char[1];
suffix[0] = Convert.ToChar(iAsciiValue);
Strvalue = Strvalue.Replace(temp[0], suffix[0]);

}
}
else
{
Strvalue = Strvalue.PadRight(Strvalue.Length + 1, 'A');

}
}
return Strvalue;
}


Comments

Author: ABitSmart22 Dec 2009 Member Level: Gold   Points : 0

Please format your resource.

Author: Alwyn Duraisingh22 Dec 2009 Member Level: Gold   Points : 1

Refer this to format your resource;

http://www.dotnetspider.com/resources/30247-Tips-for-Decorating-your-resources-get-Max.aspx



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: