C#找出字符串中第一個字母並年夜寫的辦法。本站提示廣大學習愛好者:(C#找出字符串中第一個字母並年夜寫的辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是C#找出字符串中第一個字母並年夜寫的辦法正文
本文實例講述了C#找出字符串中第一個字母並年夜寫的辦法。分享給年夜家供年夜家參考,詳細以下:
class Program
{
static void Main(string[] args)
{
String aa = "%.,46,2xb1bfs.,,";
int pos = isLetter(aa);
aa = aa.Substring(pos, 1);
Console.WriteLine(aa.ToUpper());
Console.Read();
}
public static int isLetter(string validString)
{
byte[] tempbyte = System.Text.Encoding.Default.GetBytes(validString);
int pos = 0;
for (int i = 0; i < validString.Length; i++)
{
byte by = tempbyte[i];
if ((by >= 65) && (by <= 90) || ((by >= 97) && (by <= 122)))
{
break;
}
pos++;
}
return pos;
}
}
願望本文所述對年夜家C#法式設計有所贊助。