c# - Problems with an overloaded function inside a Generic Function -


i writing function serialize data pass through socket. wanted write small function serialize 1 item.

private byte[] serializeone<t>(t data)     {         byte[] oneitem = new byte[constants.one_item_buffer];         oneitem = bitconverter.getbytes(data);         if (bitconverter.islittleendian)             oneitem.reverse();         return oneitem; } 

the problem bitconverter alwaysassumes data type bool , throws error: argument 1 cannot convert t bool. missing syntax force bitconverter use t type or not possible in c#?


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -