Answer 1, authority 100%
If this is all the code, then this line (as well as subsequent ones)
gridToXml [i] .Key = dataGridView1.Rows [i] .Cells ["Key"]. Value.ToString ();
tries to set the Key property of the object in gridToXml [i] to the value to the right of the equal sign. At this point, of course, there is nothing in gridToXml [i] but null , because first, the object must be initialized and placed in gridToXml [i] :
for (int i = 0; i & lt; gridToXml.Count (); i ++)
{
gridToXml [i] = new ClassVivod ();
...