I need a little help with the below code. I am basically reading text from a .txt file and need to be able to convert the text into an array(fam6) that i can then search for a value that is typed into a text box. If said text box search is not found i want to reply with a default message. My if then statement is really off and i would greatly apprecaite someone helping me correct my code.
private void button1_Click(object sender, EventArgs e)
{
string[] fam6 = System.IO.File.ReadAllLines(@"C:\Users\Beginerman\Documents\Visual Studio 2008\Projects\ArraySearch\ArraySearch\fam6.txt");
string value1 = Array.Find(fam6, element => element.StartsWith(textBox1.Text, StringComparison.Ordinal));
if (fam6.Contains(textBox1))
textBox2.Text = "Your search phrase was not found." + "\r\n";
textBox2.AppendText("We compared your search to 6 items.");
else (textBox1.Text.Length == (0))
textBox2.Text = "You did not enter data in the search box please enter a search request.";
else
{textBox2.Text = value1 + "\r\n" + "\r\n";
textBox2.AppendText("The system found your search phrase and has displayed it above." + "\r\n");
textBox2.AppendText("We compared your search to 6 items.");}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}