M
MarkusJNZ
Hi, I have a textbox in an asp.net app and all I want to do is store
the value of the textbox in a short if there is a value in the text
box;
I came up with the following (Where txtID is a asp.net textbox
control)
short ID = (txtID.Text != string.Empty ? short.Parse(txtID.Text) : 0);
But I get the following error
"Type of conditional expression cannot be determined because 'short'
and 'int' implicitly convert to one another"
I have tried
short ID = (txtID.Text != string.Empty ? Convert.ToInt16(txtID.Text) :
0);
and
short ID = (txtID.Text != string.Empty ? ((short)txtID.Text) : 0);
But still get errors
Any help appreciated!
Thanks
Markus
the value of the textbox in a short if there is a value in the text
box;
I came up with the following (Where txtID is a asp.net textbox
control)
short ID = (txtID.Text != string.Empty ? short.Parse(txtID.Text) : 0);
But I get the following error
"Type of conditional expression cannot be determined because 'short'
and 'int' implicitly convert to one another"
I have tried
short ID = (txtID.Text != string.Empty ? Convert.ToInt16(txtID.Text) :
0);
and
short ID = (txtID.Text != string.Empty ? ((short)txtID.Text) : 0);
But still get errors
Any help appreciated!
Thanks
Markus