I have an item array:
dtProducts.Rows[i].ItemArray;
I’m trying to append a single string value to the beginning of this array and then add the whole array to another DataTable.
I’ve tried using .ToList() on the item array, and then add the string value but it gave me an error of:
Cannot implicitly convert type ‘void’ to ‘System.Collections.Generic.List
var items = dtProducts.Rows[i].ItemArray.ToList();
items = items.Add("myString");
What am I doing wrong?
As Jason said, List<>.Add is a void method, you should remove the assingment:
If you want the new item to be in the beginning of the list, use Insert: