Hi,
I have one problem now:
I need to get the last row first column cell value from datagridview. Then minus 100 to get the finally value. Then convert this value to ushort as a parameter to one function.
Here is my code:
int line = dataGridView.Rows.Count-1;
int min = 100;
int minu=Convert.ToInt16(dataGridView.Rows[line].Cells[0].Value.ToString()) - min;
ushort max = (ushort)minu;
but I get the error said that:
Object reference not set to an instance of an object. in this line :
int minu=Convert.ToInt16(dataGridView.Rows[line].Cells[0].Value.ToString()) - min;
I do not understand what is wrong. I read a lot about int and ushort...but still do not understand..
anyone help me...
C# int and ushort computation
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

VulpesRank #55 · 29.2K reputationPosted Jun 26, 2013, 12:34 AM EDT
Emma Emma80 reputationPosted Jun 26, 2013, 12:55 AM EDT