I have written code that is well tested for performance.
in the code I am spliting a comma seperated string and assigning it to ItemArray of a DataTable Row.
DataRow dr = dt.NewRow();
var itemArray = processedUliValue.Split(',');
dr.ItemArray = itemArray;
dt.Rows.Add(dr);
Later in the code I am converting these itemArray values to integer based on selected column names
there I am getting exception if any column is empty.
So I am looking for setting the empty values to null while assigning itemArray , I tried using DBNull.Value in comma seperated string but it did not took null, I tried null as well but that also not worked.
Is there any way to assign null using this comma seperated string to ItemArray?
Looks like your column, which you’re trying to store
DbNull.Valueto, doesn’t allow nulls. This works for me: