I made a static function that returns me an ArrayList of objects:
allThread =(ArrayList) AllQuestionsPresented.GetAllThreads();
Now the objects have properties that i want to get out. But I noticed that i cant type allThreads.Name...or allThreads["Name"] , or allThreads[1], it wont give me the object itself. Cause intellisense doesnt recognize it..
Here is what I am trying to do..:
That function is in one class:
public static ICollection GetAllThreads()
{
ArrayList allThreads = new ArrayList();
string findUserID = "SELECT UserID FROM Users";
string myConnectionString = AllQuestionsPresented.connectionString;
using (SqlConnection myConnection = new SqlConnection(myConnectionString))
{
SqlCommand sqlCommand = new SqlCommand(findUserID, myConnection);
SqlDataReader reader = sqlCommand.ExecuteReader();
while (reader.Read())
{
AllQuestionsPresented allQ = new AllQuestionsPresented((Guid)reader["UserID"]);
allThreads.Add(allQ);
}
}
return allThreads;
}
That is some code from another function in another class:
forumsPages = new Dictionary<int, List<DisplayAllQuestionsTable>>();
allThread =(ArrayList) AllQuestionsPresented.GetAllThreads();//I want to convert the ICollection
for (int i = 0; i < 20; i++)
{
threads.Add(new DisplayAllQuestionsTable(allThread[i].//And use it here. I want an object to be returned..same object that was stored in the ArrayList in the static function
}