I'm trying to add an object to a List but whenever I go to check what's inside the List I get "SomeNamespace.SomeClass". I'm importing an Excel table into a 2D array and I'm passing its values to an object which I'm trying to add to a List. Here's the code (I'm excluding the part where I import the Excel file because I successfully retrieve everything I need, I just can't add it to a List):
int rowNumber= xlRange.Rows.Count;
int columnNumber= xlRange.Columns.Count;
object[,] valueArray;
List<SomeClass> list = new List<SomeClass>();
valueArray = (object[,])xlRange.get_Value(XlRangeValueDataType.xlRangeValueDefault);
for (int i = 2; i <= rowNumber; i++)
{
SomeClass objRequest = new SomeClass();
objRequest.Field1 = valueArray[i, 1].ToString();
objRequest.Field2 = valueArray[i, 2].ToString();
objRequest.Field3 = valueArray[i, 3].ToString();
objRequest.Field4 = valueArray[i, 4].ToString();
objRequest.Field5 = valueArray[i, 5].ToString();
objRequest.Field6 = valueArray[i, 6].ToString();
objRequest.Field7 = valueArray[i, 7].ToString();
list.Add(objRequest);
}
foreach (var item in list)
{
MessageBox.Show(item.ToString());
}
I'm currently using VS 2010 if it can help.
.ToString()(Which is not overridden). If you want to check specific field in message box then What is it? What istypeof that fieldSomeClass.ToString?ToString()function inSomeClass? If not you're using the default implementation, which givesNamespace.ClassName..ToString()-Method and how to override it.