publicstringGetPYString(stringstr)
{
stringtempStr="";
foreach(charcinstr)
{
if((int)c>=&&(int)c<=)
{//字母和符号原样保留
tempStr+=cToString();
}
else
{//累加拼音声母
tempStr+=GetPYChar(cToString());
}
}
returntempStr;
}
///<summary>
///取单个字符的拼音声母
///CodeByMuseStudio@hotmailcom
///
///</summary>
///<paramname="c">要转换的单个汉字</param>
///<returns>拼音声母</returns>
publicstringGetPYChar(stringc)
{
byte[]array=newbyte[];
array=SystemTextEncodingDefaultGetBytes(c);
inti=(short)(array[]’’)*+((short)(array[]’’));
if(i<xBA)return"*";
if(i<xBC)return"a";
if(i<xBC)return"b";
if(i<xBEE)return"c";
if(i<xBEA)return"d";
if(i<xBA)return"e";
if(i<xBC)return"f";
if(i<xBFE)return"g";
if(i<xBBF)return"h";
if(i<xBFA)return"g";
if(i<xCAC)return"k";
if(i<xCE)return"l";
if(i<xCC)return"m";
if(i<xCB)return"n";
if(i<xCBE)return"o";
if(i<xCDA)return"p";
if(i<xCBB)return"q";
if(i<xCF)return"r";
if(i<xCBFA)return"s";
if(i<xCDDA)return"t";
if(i<xCEF)return"w";
if(i<xDB)return"x";
if(i<xDD)return"y";
if(i<xDFA)return"z";
return"*";
}