在实现拼音检索功能前需要引入两个程序集,ChnCharInfo.dllChnCharInfo.resources.dll

例如:

 

 1 namespace 拼音检索
 2 
 3 {
 4 
 5     class Program
 6 
 7     {
 8 
 9         static void Main(string[] args)
10 
11         {
12 
13             Console.WriteLine("请输入一句中文");
14 
15             string str = Console.ReadLine();
16 
17             StringBuilder sb = new StringBuilder();
18 
19             foreach (char item in str)
20 
21             {
22 
23                 if (ChineseChar.IsValidChar(item))
24 
25                 {
26 
27                     ChineseChar ch = new ChineseChar(item);
28 
29  
30 
31                     sb.Append(ch.Pinyins[0].Substring(0, ch.Pinyins[0].Length - 1));
32 
33  
34 
35                 }
36 
37                 else
38 
39                 {
40 
41                     sb.Append(item);
42 
43                 }
44 
45             }
46 
47             Console.WriteLine(sb.ToString());
48 
49             Console.ReadKey();
50 
51         }
52 
53     }
54 
55 }

 

 

 

 

相关文章:

  • 2021-11-01
  • 2021-07-18
  • 2021-08-06
  • 2022-01-18
  • 2021-12-12
  • 2021-09-21
猜你喜欢
  • 2022-12-23
  • 2021-04-28
  • 2022-12-23
  • 2021-07-16
  • 2021-07-26
相关资源
相似解决方案