ByteBuffer implementation for dotNET
Today I created a dotNET version of ByteBuffer class, with this class you can easily read and write data into byte array. You can get the source file here.
Here’s an example about how to use ByteBuffer class:
Program.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace TestCode { class Program { static void Main(string[] args) { ByteBuffer buffer = new ByteBuffer(20); buffer.AddInt(10); buffer.AddString("Test"); buffer.AddLong(10000); buffer.AddInt(350); buffer.AddChar('c'); buffer.AddDouble(10000.325); Console.WriteLine(buffer.ReadInt()); Console.WriteLine(buffer.ReadString()); Console.WriteLine(buffer.ReadLong()); Console.WriteLine(buffer.ReadInt()); Console.WriteLine(buffer.ReadChar()); Console.WriteLine(buffer.ReadDouble()); Console.ReadLine(); } } } |
My implementation doesn’t contains all features found on Java version of the same class, but can help on most cases.
Ai, legal heim _o/
August 3rd, 2009 | #