全角字符与半角字符的相互转换(C#)

     看到视频里有做这个例子,对着视频把代码打了一遍,测试成功,先记下来,以备后用!!!

Code

测试代码:

        static void Main(string[] args)
        {
            Console.Write(
"请输入要转为半角的字符:");
            
string str = Console.ReadLine();
            Console.WriteLine(
"半角:" + new ConvertDBCAndSBC().SBCToDBC(str));
            Console.ReadLine();

            Console.Write(
"请输入要转为全角的字符:");
            
string str2 = Console.ReadLine();
            Console.WriteLine(
"全角:" + new ConvertDBCAndSBC().DBCToSBC(str2));
            Console.ReadLine();
        }

测试效果:

 

撸码:复制、粘贴,拿起键盘就是“干”!!!
原文地址:https://www.cnblogs.com/niunan/p/1517994.html