I am a student currently workin on a project I am now stuck on my search button im using arrays
of which my single array will go and select a column and save it then the if statement states if that certain is selected then all the details of it should be displayed currently there are no errors I just think it is a matter of displaying that information ...below is the preview of the code behind my button and a preview of the text file as to how it is lay out. I'm new so please use simple language as possible
''Name:' 'Mandiso' 'Ngwenya' 'Date:' '3' 'June' 'Contact' 'Details:' '+277883935
these ( ' ') characters represent that the is just a space in-between the words in the line
protected void btnSearch_Click(object sender, EventArgs e)
{
try
{
using (StreamReader MyFriend = new StreamReader(@"C:\Friends3\Friends.txt"))
{
string[][] find = null;
int inc = 0;
String line;
while ((line = MyFriend.ReadLine())!= null)
//Arrays
{
string[] Friends = line.Split(' ');
if ((DDL0.SelectedItem.Text).Equals(Friends[5]))
{
find[inc][inc] = Friends[1];
find[inc][inc + 1] = Friends[2];
find[inc][inc + 2] = Friends[4];
find[inc][inc + 3] = Friends[5];
find[inc][inc + 4] = Friends[8];
inc++;
}
}
// using for statement to display from arrays
for (int i = 0; i < find.Length; i++)
{
for (int c = 0; c < 5; c++)
{
LLB.Items.Add(find[i][c].ToString());
}
}
}
}
catch (Exception ex)
{
Console.WriteLine("The file could not be read:");
Console.WriteLine(ex.Message);
}
}
}
}