How can i add column name in list generic?
Posted
by Phsika
on Stack Overflow
See other posts from Stack Overflow
or by Phsika
Published on 2010-06-14T08:20:53Z
Indexed on
2010/06/14
8:22 UTC
Read the original article
Hit count: 159
class MyExcelSheets
{
public List MyColumnNames { get; set; }
}
how can i add Excel data's column name in "List MyColumnNames ". it returns to me Object reference not set to an instance of an object.
i want to use above class in:
myexcelSheet = new MyExcelSheets();
myexcelSheet.MyColumnNames = new MyExcelSheets().MyColumnNames;
foreach (DataColumn col in dTable.Columns)
myexcelSheet.MyColumnNames.Add(col.ColumnName.ToString());
How can i solve it?
Error: NullReferenceException© Stack Overflow or respective owner