- Home /
Question by
unity_YckkrP5h-MVruA · Jan 08, 2021 at 08:24 PM ·
null reference exception
System.NullReferenceException DataTable
Hi!
I have this code:
DataTable dt = new DataTable();
dt.Columns.Add("Name");
DataRow rowNew = dt.NewRow();
rowNew["Name"] = "Karl";
dt.Rows.Add(rowNew);
In VS 2019 I don't have magnifire on datatable. DataTable Visualizator is not working.
In Immediate Window I try "dt.Rows[0]["Name"].ToString()" and get this:
System.NullReferenceException: Object reference not set to an instance of an object.
I tried to use".Net 4.x" - it was useless. This happens only in Unity. I tested with a C# compiler and it works. Could you help me?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613022938im_/https://answers.unity.com/themes/thub/images/avi.jpg)