Osc.InsertString C# (CSharp) 메소드

InsertString() 개인적인 정적인 메소드

Inserts a string, correctly padded into a packet. Used internally.
private static InsertString ( string s, byte packet, int start, int length ) : int
s string
packet byte The packet of bytes to be parsed.
start int The index of where to start looking in the packet.
length int The length of the packet.
리턴 int
    private static int InsertString(string s, byte[] packet, int start, int length)
    {
      int index = start;
      foreach (char c in s)
      {
        packet[index++] = (byte)c;
        if (index == length)
          return index;
      }
      packet[index++] = 0;
      int pad = (s.Length+1) % 4;
      if (pad != 0)
      {
        pad = 4 - pad;
        while (pad-- > 0)
          packet[index++] = 0;
      }
      return index;
    }