标签:
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(); } }
标签:
原文地址:http://www.cnblogs.com/phpweige/p/4776008.html