Hi, Quite interested in knowing why you are doing this?To Quote Jesse Liberty
in his book Programming C# : "That said, memory is fairly cheap, and
programmer time is increasingly expensive; most of the time
you'll simply declare your variables to be of type int, unless there is a
good reason to do otherwise.
The signed types are the numeric types of choice of most programmers unless
they have a good
reason to use an unsigned value.
Although you might be tempted to use an unsigned short to double the
positive values of a signed
short (moving the maximum positive value from 32,767 up to 65,535), it is
easier and preferable to
use a signed integer (with a maximum value of 2,147,483,647). "
Try:
ushort uSigned = 65535;
short signed = 0;
signed = (short)uSigned;
Console.WriteLine("Short == {0}" , signed);
ushort newUnSigned = (ushort)signed;
Console.WriteLine("UShort == {0}", newUnSigned);
Console.WriteLine("Values Equal ? : {0}" , (uSigned ==
newUnSigned));
"ra***********@gmail.com" wrote:
HI
I have a problem in casting short to ushort in my project.
i have a ushort value of 38,143 now it is converted into short value of
27,393 and stored in variable.(when i casted ushort to short)
1. now how can i get back value 38,143 from short variable value 27,393
?
2. how can i check whether the conversion of value happned when i
casted
from ushort to short ?
if anybody have idea please let me know, thanks