码迷,mamicode.com
首页 > Windows程序 > 详细

C#------火星文翻译器

时间:2015-09-01 16:52:34      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:

 class Program
    {
        static void Main(string[] args)
        {
            //火星文翻译器
            string StrKey = "";
            string StrValue = "";

            Dictionary<char, char> dic = new Dictionary<char, char>();

            for (int i = 0; i < StrKey.Length; i++)
            {
                char key = StrKey[i];
                char value = StrValue[i];
                //加入字典
                dic[key] = value;
            }

            string msg = "我aaaaa";
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < msg.Length; i++)
            {
                char key = msg[i];
                char? value = null;

                if (dic.ContainsKey(key))
                {
                    value = dic[key];
                }
                else
                {
                    value = key;
                }

                sb.Append(value);
            }
            string s = sb.ToString();
            Console.WriteLine(s);
            Console.ReadKey();
        }
    }

 

C#------火星文翻译器

标签:

原文地址:http://www.cnblogs.com/phpweige/p/4776008.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!