arrays - reinterpret_cast in C# -


I am looking for a way to redefine a type of byte [] in a different way, Brief [] says that in C ++ it can be obtained by a simple artist, but in C # I have not found any way to achieve this without duplicating the whole buffer.

Any thoughts?

You can get it but this is a relatively bad idea. - Not safe and can only be done under full confidence security environment. You should never do this properly in the managed applications designed If your data is being masking in two different forms, then maybe you have two separate data sets?

In any case, a quick and simple code snippet to complete what you asked:

  byte [] bytes = new byte [] (1 , 2, 3, 4, 5, 6, 7, 8, 9, 10}; int byteCount = bytes.Length; unsafe {// using certain keywords, we fix the array in a static memory location. / Otherwise, the garbage collector can move it, while we are still using it! Fix (byte * bytepointer = bytes) {short * shortPointer = (short *) bytePointer; (Int Ind (Console), Viralline ("short {0}: {1}", index, short pointer [index]);}}}  for console (byte = 0; index & lieutent; 

Comments