Facing new challenges everyday

ByteBuffer implementation for dotNET

August 2nd, 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.

Post to Twitter

1 Comment »

  1. Fred says

    Ai, legal heim _o/

    August 3rd, 2009 | #

Leave a comment

:mrgreen: :neutral: :twisted: :shock: :smile: :???: :cool: :evil: :grin: :oops: :razz: :roll: :wink: :cry: :eek: :lol: :mad: :sad:
Imagem CAPTCHA

RSS feed for these comments. | TrackBack URI

Visitors Around the World

Polls

How Is My Site?

View Results

Loading ... Loading ...

Categories

Meta

Links

hosted by easy2use.net