日期:2014-05-19  浏览次数:20536 次

把英文的第一个字母转换成大写
如把
are   you   kidding   me?
转换成
Are   You   Kidding   Me?



------解决方案--------------------
public static string strLast = " ";
private void Form1_Load(object sender, EventArgs e)
{
string strEng = "are you kidding me? ";
string[] strItem = strEng.Split(char.Parse( " "));
for (int i = 0; i < strItem.Length ; i++)
{
string strUp = strItem[i];
string strEngFirst = strUp.Substring(0, 1).ToUpper();
string strEngEnd = strUp.Substring(1, (strUp.Length - 1));
strUp = strEngFirst + strEngEnd;
strLast = strLast + " " + strUp;
}
}
------解决方案--------------------
string str = "are you kidding me? ";
string[] substrings = str.split( " ");
str = " ";
for(int i=0;i <substrings.Length;i++)
{
substrings[i] = substrings[i].Substring(0,1).ToUpper() + substrings[i].Substring(1,substrings[i].Length-1);
str += substrings[i] + " ";
}
str = str.Substring(0,str.Length-1);
这个有点像MS的面试题