Search Unity

Extracting segments of data from a byte array

Discussion in 'Scripting' started by Kloper, May 22, 2015.

  1. Kloper

    Kloper

    Joined:
    Jan 28, 2014
    Posts:
    93
    I am getting a stream of data (int32, string, char, float and so on) into an byte array.

    "byte[] data = client.Receive(refIP);"

    My problem is that I dont know how to exact segments form that array.
    Basically take the array and say, first 4 bits go into this variable, next 8 bits into another and so on.

    Hope someone has a c# solution for me.

    Thanks in advanced!!
     
  2. Cyras

    Cyras

    Joined:
    Nov 26, 2012
    Posts:
    14
  3. Kloper

    Kloper

    Joined:
    Jan 28, 2014
    Posts:
    93
    Thanks alot!!! this looks like exactly what I need.