S
stuie_norris
Hi Group,
I have had a go at defining a data type for handle 3 byte data (24
Bit). I want to be able to
use the datatype like a normal datatype such as int, short etc. Plus
I wish to have some extra
methods that allow me get specific bytes if needed.
Here is what I have tried.
using System;
using System.Collections.Generic;
using System.Text;
namespace mytype
{
class Program
{
static void Main(string[] args)
{
byte[] a = new byte [3];
byte[] b = { 0x1, 0x2, 0x3 };
Bit24 bit24 = b;
a = bit24;
byte byte1 = bit24.setbyte(1, 0x01);
byte byte2 = bit24.getbyte(1);
}
}
public class Bit24
{
private byte[] _value = new byte[3];
public Bit24(byte[] value)
{
_value = value;
}
public byte getbyte(int field)
{
return _value[field];
}
public byte setbyte(int field, byte value)
{
_value[field] = value;
}
}
}
Thanks
Stuart
I have had a go at defining a data type for handle 3 byte data (24
Bit). I want to be able to
use the datatype like a normal datatype such as int, short etc. Plus
I wish to have some extra
methods that allow me get specific bytes if needed.
Here is what I have tried.
using System;
using System.Collections.Generic;
using System.Text;
namespace mytype
{
class Program
{
static void Main(string[] args)
{
byte[] a = new byte [3];
byte[] b = { 0x1, 0x2, 0x3 };
Bit24 bit24 = b;
a = bit24;
byte byte1 = bit24.setbyte(1, 0x01);
byte byte2 = bit24.getbyte(1);
}
}
public class Bit24
{
private byte[] _value = new byte[3];
public Bit24(byte[] value)
{
_value = value;
}
public byte getbyte(int field)
{
return _value[field];
}
public byte setbyte(int field, byte value)
{
_value[field] = value;
}
}
}
Thanks
Stuart