Dictionary<string, string> nameage = new Dictionary<string, string>();
private void btn_Click(object sender, RoutedEventArgs e)
{
string str = null;
string[] strArrname = null;
str = tb.Text;
string agee = agetb.Text;
char[] splitchar = { ' ' };
strArrname = str.Split(splitchar);
string[] strarrayage = agee.Split(splitchar);
for (int name = 0; name < strArrname.Length ; name++)
{
for(int age=0; age ==name; age++)
{
nameage.Add(strArrname[name],strarrayage[age]);
}
}
tb.Text = "";agetb.Text = "";
}
private void search_Click(object sender, RoutedEventArgs e)
{
string nameAGE = tb.Text;
foreach (KeyValuePair<string, string> d in nameage)
{
if (d.Value == nameAGE)
{
agetb.Text = "Name is " + " " + d.Value + " " + "Age is " + " " + d.Key;
}
else if(d.Key == nameAGE)
{
agetb.Text = "Name is " + " " + d.Value + " " + "Age is " + " " + d.Key;
}
}
}