How to cast some negative number to unsigned types
.
Type type = typeof (ushort);
short num = -100;
ushort num1 = unchecked ((ushort) num); //When type is known. Result 65436
ushort num2 = unchecked(Convert.ChangeType(num, type)); //Need here the same value
Aucun commentaire:
Enregistrer un commentaire