ByteBuffer implementation for dotNET

Posted by – August 2, 2009

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.

Share

1 Comment on ByteBuffer implementation for dotNET

  1. Fred says:

    Ai, legal heim _o/

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>