You can use the text.Replace(pair.Key, pair.Value) function text.Replace(pair.Key, pair.Value) .
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace Transliter { public partial class Form1 : Form { Dictionary<string, string> words = new Dictionary<string, string>(); public Form1() { InitializeComponent(); words.Add("", "a"); words.Add("", "b"); words.Add("", "v"); words.Add("", "g"); words.Add("", "d"); words.Add("", "e"); words.Add("", "yo"); words.Add("", "zh"); words.Add("", "z"); words.Add("", "i"); words.Add("", "j"); words.Add("", "k"); words.Add("", "l"); words.Add("", "m"); words.Add("", "n"); words.Add("", "o"); words.Add("", "p"); words.Add("", "r"); words.Add("", "s"); words.Add("", "t"); words.Add("", "u"); words.Add("", "f"); words.Add("", "h"); words.Add("", "c"); words.Add("", "ch"); words.Add("", "sh"); words.Add("", "sch"); words.Add("", "j"); words.Add("", "i"); words.Add("", "j"); words.Add("", "e"); words.Add("", "yu"); words.Add("", "ya"); words.Add("", "A"); words.Add("", "B"); words.Add("", "V"); words.Add("", "G"); words.Add("", "D"); words.Add("", "E"); words.Add("", "Yo"); words.Add("", "Zh"); words.Add("", "Z"); words.Add("", "I"); words.Add("", "J"); words.Add("", "K"); words.Add("", "L"); words.Add("", "M"); words.Add("", "N"); words.Add("", "O"); words.Add("", "P"); words.Add("", "R"); words.Add("", "S"); words.Add("", "T"); words.Add("", "U"); words.Add("", "F"); words.Add("", "H"); words.Add("", "C"); words.Add("", "Ch"); words.Add("", "Sh"); words.Add("", "Sch"); words.Add("", "J"); words.Add("", "I"); words.Add("", "J"); words.Add("", "E"); words.Add("", "Yu"); words.Add("", "Ya"); } private void button1_Click(object sender, EventArgs e) { string source = textBox1.Text; foreach (KeyValuePair<string, string> pair in words) { source = source.Replace(pair.Key, pair.Value); } textBox2.Text = source; } } }
If you change
cryllic to latin:
text.Replace(pair.Key, pair.Value);
latin to cryllic
source.Replace(pair.Value,pair.Key);