This code is a simple dictionary translator. Can I use StringComparison.CurrentCultureIgnoreCasethat when entering a textBox1word that is not taken into account for registration, you?
using System.Text;
using System.IO;
using System.Windows.Forms;
namespace d
{
public partial class Form1 : Form
{
Dictionary<string, string> dictionary = new Dictionary<string, string>();
public Form1()
{
InitializeComponent();
StreamReader sr = new StreamReader("test.txt", Encoding.UTF8);
string[] split;
while (!sr.EndOfStream)
{
split = sr.ReadLine().Split(new char[] { '^' }, StringSplitOptions.RemoveEmptyEntries);
if (!dictionary.ContainsKey(split[0]))
{
dictionary.Add(split[0], split[1]);
}
}
sr.Close();
sr.Dispose();
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Focus();
string word = textBox1.Text;
if (dictionary.ContainsKey(word))
{
textBox2.Text = dictionary[word];
}
else
{
MessageBox.Show("not found");
}
}
}
}
source
share