BitTorrent.ValueString.Encode C# (CSharp) Method

Encode() public method

public Encode ( ) : byte[]
return byte[]
        public byte[] Encode()
        {
            string prefix = v.Length.ToString() + ":";
            byte[] tempBytes = Encoding.GetEncoding(1252).GetBytes(prefix);

            byte[] newBytes = new Byte[prefix.Length + data.Length];
            for (int i = 0; i < prefix.Length; i++) newBytes[i] = tempBytes[i];
            for (int i = 0; i < data.Length; i++) newBytes[i + prefix.Length] = data[i];
            return newBytes;
        }

Usage Example

 public byte[] Encode()
 {
     Collection<byte> collection1 = new Collection<byte>();
     collection1.Add(100);
     ArrayList list1 = new ArrayList();
     foreach (string text1 in dict.Keys)
     {
         list1.Add(text1);
     }
     foreach (string text2 in list1)
     {
         ValueString text3 = new ValueString(text2);
         foreach (byte num1 in text3.Encode())
         {
             collection1.Add(num1);
         }
         foreach (byte num2 in dict[text2].Encode())
         {
             collection1.Add(num2);
         }
     }
     collection1.Add(0x65);
     byte[] buffer1 = new byte[collection1.Count];
     collection1.CopyTo(buffer1, 0);
     return buffer1;
 }
All Usage Examples Of BitTorrent.ValueString::Encode