The concept of a C++ vector
is roughly equivalent in functionality to the generic List<T>
class in C#.
As SLaks said, the best solution, given you know the types and that each set of three columns is a "row" in the table, is to create a simple class that holds your Column A, B, and C, then create a list of those:
public class ExcelData
{
public string PersonName {get;set;}
public int Age {get;set;}
public string PhoneNumber {get;set;}
}
public List<ExcelData> fromExcel = new List<ExcelData>();
fromExcel.Add(new ExcelData
{
PersonName = "Joe Smith",
Age = 34,
PhoneNumber = "(123) 456-7890"
});
If you're using .NET 4 (which, since you're using VS 2010, you should be), there's a class Tuple
, which has several generic overloads and a static helper to create them:
public List<Tuple<string, int, string>> fromExcel = new List<Tuple<string, int, string>>();
...
fromExcel.Add(Tuple.Create("Joe Smith", 34, "(123) 456-7890"));
The upside is a built-in, flexible class; the downside is that a Tuple is very general-purpose and so its column names are similarly general-purpose; Item1, Item2, etc.