Search code examples
c#arraysreflectionintshort

reflection GetBytes from int, int16, int64


how can i get the value of int, int16/short, int64 as byte[]

if data type is only known as object

I have some ideas like parse the Type-Name and foreach the int32-length-array

but i was wondering if there is a way with correct reflection.


Solution

  • Have a look at BitConverter.GetBytes