C++/C# endline char checking in byte array

B

Brian Henry

I am looking at this article http://www.developerfusion.com/show/4472/4/

and at one point in the code

private string Response()
{
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
byte [] serverbuff = new Byte[1024];
NetworkStream stream = GetStream();
int count = 0;
while (true)
{
byte [] buff = new Byte[2];
int bytes = stream.Read(buff, 0, 1 );
if (bytes == 1)
{
serverbuff[count] = buff[0];
count++;

if (buff[0] == '\n')
{
break;
}
}
else
{
break;
};
};
string retval = enc.GetString(serverbuff, 0, count );
Debug.WriteLine(" READ:" + retval);
return retval;
}

if says if (buff[0] == '\n')

that i know how to do in C++ and C# it's just an endline char, but if i use
controlchars.Cr it gives me an erro byte cant be cast to char... how would
you guys handle this? thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top