#region 返回字符串各字首字母
    
private string GetLetterFromString(string str)
    {
        
string tempStr = "";
        
foreach (char c in str)
        {
            
if (((int)c >= 33&& ((int)c <= 126))
            {
                
//字母和符号原样保留 
                tempStr += c.ToString();
            }
            
else
            {
                
//累加拼音声母
                tempStr += GetLetterFromChar(c.ToString());
            }
        }
        
return tempStr;
    }

    
/// <summary>
    
/// 返回单个字的字母
    
/// </summary>
    
/// <param name="ch"></param>
    
/// <returns></returns>
    public string GetLetterFromChar(string str)
    {
        
if (str.CompareTo(""< 0return str;
        
if (str.CompareTo(""< 0return "a";
        
if (str.CompareTo(""< 0return "b";
        
if (str.CompareTo(""< 0return "c";
        
if (str.CompareTo(""< 0return "d";
        
if (str.CompareTo(""< 0return "e";
        
if (str.CompareTo(""< 0return "f";
        
if (str.CompareTo(""< 0return "g";
        
if (str.CompareTo(""< 0return "h";
        
if (str.CompareTo(""< 0return "j";
        
if (str.CompareTo(""< 0return "k";
        
if (str.CompareTo(""< 0return "l";
        
if (str.CompareTo(""< 0return "m";
        
if (str.CompareTo(""< 0return "n";
        
if (str.CompareTo(""< 0return "o";
        
if (str.CompareTo(""< 0return "p";
        
if (str.CompareTo(""< 0return "q";
        
if (str.CompareTo(""< 0return "r";
        
if (str.CompareTo(""< 0return "s";
        
if (str.CompareTo(""< 0return "t";
        
if (str.CompareTo(""< 0return "w";
        
if (str.CompareTo(""< 0return "x";
        
if (str.CompareTo(""< 0return "y";
        
if (str.CompareTo(""< 0return "z";
        
return str;
    }
    
posted on 2009-10-27 11:30  collinye  阅读(621)  评论(0编辑  收藏  举报