标签:
1. 代码如下:
????private void button1_Click(object sender, EventArgs e)
{
string userInto = textBox1.Text.Trim();
textBox2.Text = GetPinYin(userInto);
}
?
private string GetPinYin(string userInto)
{
StringBuilder sb=new StringBuilder();
????????????//遍历字符串中的字符
foreach (char item in userInto)
{
ChineseChar chineseChar=new ChineseChar(item);
//遍历各个拼音
foreach (var itemPy in chineseChar.Pinyins)
{
sb.Append(itemPy.Substring(0, itemPy.Length - 1));
//取出第一个,作为该字符的拼音
break;
}
}
return sb.ToString();
}
标签:
原文地址:http://www.cnblogs.com/taidou/p/4713463.html