I want add every row data from csv into Dictionary in c#
csv is like that :
- id,data
- 1,a
- 2,b
here my code
Dictionary<int, string> m_dicTransactions = new Dictionary<int, string>();
while ((line = sr.ReadLine()) != null)
{
string[] columns = line.Split(',');
m_dicTransactions.Add(columns[0], columns[1]);
}
i want to add id and data to my dictionary, how to do that?
You need to convert the first column to an integer: