Hi,
I have a class that holds data in array of byte. It has property to get the
data like this (FBuffer is a byte[]):
public byte[] Data
{
get { return FBuffer; }
}
But for display / debugging purposes I have a property that returns the data
as a string like this:
public string DataToString
{
get
{
StringBuilder sb = new StringBuilder(FLength + 1);
int i = 0;
while (i < FLength) {
char chr = (char)FBuffer[i];
sb.Append(chr);
i++;
}
return sb.ToString();
}
}
It woks, but it would be nicer to have a .ToString() or something that I can
add to the property Data. Is this possible and if yes, how should I code this?
eg now:
byte[] b = Buf.Data;
string s = Buf.DataToString;
and I like to have something as:
string s = Buf.Data.ToString();
--
rgds, Wilfried
http://www.mestdagh.biz