I have a simple generic method.
The idea is that I can use this method with either a ushort or uint for T.
But I get the following error.
Error CS1503 Argument 1: cannot convert from 'T' to 'bool'
The error I believe is generated because one of the overloads for BitConverter.GetBytes is bool .
I just do not have a clue on how to resolve this, other than write my own method to convert a unit or ushort to bytes. Any suggestions or hints appreciated.
Code:
private static byte[] GetBytes<T> (T valu)
{
var bytes = BitConverter.GetBytes(valu);
if (BitConverter.IsLittleEndian)
Array.Reverse(bytes);
return bytes;
}
But I get the following error.
Error CS1503 Argument 1: cannot convert from 'T' to 'bool'
The error I believe is generated because one of the overloads for BitConverter.GetBytes is bool .
I just do not have a clue on how to resolve this, other than write my own method to convert a unit or ushort to bytes. Any suggestions or hints appreciated.