Cannot convert type 'string' to 'ushort'

  • Thread starter Thread starter Marcelo Muzilli
  • Start date Start date
M

Marcelo Muzilli

Howdy all,

in my program, I have a ushort variable and a string variable and if I
try to compile it, I'm receiving this error message: "Cannot convert
type 'string' to 'ushort'".

How can I compare both?

Example:

if ( uVariable != sVariable ) { ... }

Tia,

Marcelo Muzilli
 
Hi,


There is no implicit conversion between the two types. either you convert
the string to number or the number to string:

ushortvar.ToString == stringVar

or

Convert.ToUnit16( stringVar ) == ushortvar
 
Back
Top