zoukankan      html  css  js  c++  java
  • C#中如何获取汉字的笔画数和汉字的拼音

    以前玩过一个游戏,输入两个人的名字然后点击缘分就能产生一段缘分测试的结果,后来经过分析知道是根据名字笔画数之差来弄的小游戏,于是就在百度上找怎么得到汉字的笔画数,也没找到自己想要的答案,问遍了所有的人也不知道怎么弄的,终于功夫不负有心人找到答案了,现在分享给大家!

    第一步:添加DLL文件的引用

    DLL下载地址:点此下载

    第二步

    using System;
    using System.Collections.Generic;
    using System.Text;
    using Microsoft.International.Converters.PinYinConverter;
    
    namespace Example_CS
    {
        class Program
        {
            static void Main(string[] args)
            {
                ChineseChar chineseChar = new ChineseChar('');
                Console.WriteLine("Stroke number of 微 in Chinese is {0}.", chineseChar.StrokeNumber);
                Console.WriteLine("{0} characters' pinyin is "wei1".", ChineseChar.GetHomophoneCount("wei1"));
                if(ChineseChar.IsHomophone('', ''))
                {
                    Console.WriteLine("微 and 薇 have the same pinyin.");
                }
                else
                {
                    Console.WriteLine("微 and 薇 have different pinyins.");
                }
            }
        }
    }

    其中上面的属性和方法中:StrokeNumber属性用来获取字符的笔画数;

    Pinyins方法

    获取这个字符的拼音。
  • 相关阅读:
    Load样式——1
    通过mybatis-generator-core-1.3.2.jar逆向工程生成
    阶乘
    八进制
    xshell跳转设置 Xshell代理设置
    spark
    内存模型学习-- Container Executor task之间的关系
    scala 学习笔记--闭了个包
    scala 学习笔记--模式匹配
    scala 学习笔记--集合
  • 原文地址:https://www.cnblogs.com/yabisi/p/6056521.html
Copyright © 2011-2022 走看看