C# - How to use DataTable on System.Data Assembly?
I have an error when using the System.Data namespace, I'm trying to read a CSV file into a DataTable object.
using System; using System.Data; class MainClass { public static void Main (string[] args) { DataTable exampleData = new DataTable(); exampleData = ConvertToDataTable("./example.csv", 2); foreach (DataRow dataRow in exampleData.Rows) { foreach (var item in dataRow.ItemArray) { Console.WriteLine(item); } } } public DataTable ConvertToDataTable (string filePath, int numberOfColumns) { ... } }
main.cs(2,14): error CS0234: The type or namespace name
Data' >does not exist in the namespace
System'. Are you missing >`System.Data' assembly reference?