Exemplo n.º 1
0
        private string GetPinyinWithTone(WordLibrary wl)
        {
            var sb = new StringBuilder();

            for (int i = 0; i < wl.Word.Length; i++)
            {
                char   c      = wl.Word[i];
                string py     = wl.PinYin[i];
                string pinyin = PinyinHelper.GetPinyinWithToneOfChar(c, py);
                if (pinyin == null)
                {
                    throw new Exception("找不到字[" + c + "]的拼音");
                }
                sb.Append(pinyin);
                if (i != wl.Word.Length - 1)
                {
                    sb.Append(" ");
                }
            }
            return(sb.ToString());
        }