unsafe - How to convert fixed byte/char[100] to managed char[] in C#? -


What is the best way to change a managed byte or four [Q] [in] C #? I have finished using the indicative arithmetic and I am thinking that there is no easy way - something like a mempi or another?

  using the system; Using System.Collections.Generic; Using System.Linq; Using System.Runtime.InteropServices; Using System.Text; Namespace Structure Test {[Layout layout (layout kick)] Unsafe structure external type {Private contact int BUFFER_SIZE = 100; [Field Offset (0)] Private int transaction type; [Field Offset (0)] Write a personalized byte buffer [buffs]; Public Int Transaction Type {Receipt {Return Transaction Type; } Set {transactionType = value; }} Public four [] write buffer {set {char [] newBuffer = value; Fixed (byte * b = writeBuffer) {byte * bptr = b; For (int i = 0; i & lt; neubber langti; i ++) {* bptr ++ = (byte) neufer [ii]; }}} Get {char [] newBuffer = new four [BUFFER_SIZE]; Fixed (byte * b = writeBuffer) {byte * bptr = b; For (int i = 0; i & lt; neubber; langith; i ++) {nu bufar [ii] = (four) * bptr ++; }} Returned Newberf; }}} Class program {static zero main (string [] args) {outtip T = new external type (); T.WriteBuffer = "Hello Ho". ToCharArray (); System.Console.WriteLine (t.WriteBuffer); }}}  

You can use it for this notice [by] It is also overloaded, which can be a suitable data type.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -