Emma Emma

Emma Emma

  • NA
  • 101
  • 55.5k

C# int and ushort computation

Jun 26 2013 4:26 AM
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...

Answers (2)