ArrayList as Array of Object Arrays
Many people know that ArrayList is Array of Objects in CLR. However less know that ArrayList can contain Array of Object Arrays in other words be multi-dimensional. For example it can contain data structure equivalent to database table structure.
LOL. I remember I was at job interview several years ago and the guy who interviewed me insisted that it was impossible. He thought I don't know what I'm talking about and wanted to stop the interview. What a feeling that should be - you interview someone and suddenly understand that you are plain wrong !
I just mentioned then that database table data can be copied to ArrayList with 3 lines of code (using SqlDataReader)...
Need just to remember that Object[] is still Object in CLR:
ArrayList rowList = new ArrayList(); IDataReader reader = cmd.ExecuteReader(); while(reader.Read()) { object[] ob = new object[reader.FieldCount]; reader.GetValues[ob]; rowList.Add(ob); }
.NET 2.0's Generics is another story...
Monday, May 21, 2007 3:19 AM