I am posting my question again because i can not add my answers in it so here is the code
static void Main(string[] args)
{
string fileA= "B.txt";
IList listA= new ArrayList();
FileReader(fileA, ref listA);
for (int i = 0; i < listA.Count; i++)
{
Console.WriteLine(listA[i].ToString());
}
Console.ReadKey();
}
public static void FileReader(string filename, ref IList result)
{
using (StreamReader sr = new StreamReader(filename))
{
string firstName;
string SecondName;
while (!sr.EndOfStream)
{
firstName= sr.EndOfStream ? string.Empty : sr.ReadLine();
SecondName= sr.EndOfStream ? string.Empty : sr.ReadLine();
result.Add(new Person(firstName, SecondName));
}
}
}
and i am getting values in my list as [0] ={"firstname","lastname"} [1]={"firsname2","secondname2"}
these values are attached with the Person class so if i want to change the lastname value of index [1] then how to do it? i can get the index [1] values but how to access the Person variable which are linked to that index