字符转ASCII码:public static int Asc(string character) { if (character.Length == 1) { System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding(); int intAsciiCode = (int)asciiEncoding.GetBytes(character)[0]; return (intAsciiCode); } else { throw new Exception("Character is not valid."); } } 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/zbking/archive/2006/06/22/822040.aspx
惭愧 没弄过那个Ascii码,要用哪个类?怎么弄?
{
if (character.Length == 1)
{
System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
int intAsciiCode = (int)asciiEncoding.GetBytes(character)[0];
return (intAsciiCode);
}
else
{
throw new Exception("Character is not valid.");
} }
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/zbking/archive/2006/06/22/822040.aspx
Console.Write(s.Substring(0,5)+(char)((int)s.ToCharArray()[5] + 1));
{
StringBuilder strS = new StringBuilder(str.Substring(0, str.Length - 1).ToString()); int temp =(int)str[str.Length - 1];
if (temp <= 122)//z的ASCII值是122
{
temp = temp + 1;
}
else
{
//如果字符串最好一个字母为z的处理方式
}
strS.Append((char)temp);
return strS.ToString();
}
{
static void Main(string[] args)
{
string a = "1234ed";
Console.WriteLine(IncreaseAscii(a));//输出1234ee
Console.ReadKey();
}
public static string IncreaseAscii(string character)
{ System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
byte[] bs = asciiEncoding.GetBytes(character);
bs[bs.Length - 1]++;
return asciiEncoding.GetString(bs); }
}