Closed endel closed 7 years ago
This is really annoying :( when the number grows, it cannot be casted to byte
anymore, and neither int
, but it works for uint
.
> message[4]
85113
> (int)message[4]
Invalid cast.
> (byte)message[4]
Invalid cast.
> (uint)message[4]
85113
Hi @endel. You are trying to unbox wrong type. Unbox operation is not 'conversion' to desired type it is 'extraction' value of desired type from object.
MessagePack serializer doesn't preserve number type during serialization/deserialization process. It is inherited from message pack format. For example when you serialize 1024(Int32) it would be written as 0xcd[uint 16] token and deserialized as UInt16.
Easiest approach to workaround this problem is to use Convert.ToInt32 method.
Awesome, thanks for the clarification!
Hey there,
I'm curious why I can't cast a value directly to
int
? See my REPL output:Isn't
53
castable toint
?Cheers!