How to convert string , date, time, byte into bitarray in C# -
i trying functions converting string bitarray, date bitarray time bitarray byte bit array. can please me these functions in c#.
for completeness, i'll include method turning arbitrary objects byte arrays (it's faster binaryformatter , memorystream):
public static byte[] tobytearray(object obj) { int len = marshal.sizeof(obj); byte[] arr = new byte[len]; intptr ptr = marshal.allochglobal(len); marshal.structuretoptr(obj, ptr, true); marshal.copy(ptr, arr, 0, len); marshal.freehglobal(ptr); return arr; }
Comments
Post a Comment