Hi,
Can anyone explain the following behaviour?
private static int BUFFER_SIZE = 1024;
private byte [] Buffer = new byte[BUFFER_SIZE];
private Encoding ASCII = Encoding.ASCII;
private System.Net.Sock ets.Socket mySocket;
// Already accepted a connection...
int Length = mySocket.Receiv e(Buffer);
String str1 = ASCII.GetString (Buffer);
String str2 = ASCII.GetString (Buffer, 0, Length);
bool Same = (str1 == str2)
// Same is false!!!!!
// I only found this out because I was trying to open
// a file using str1 as the filename as follows...
StreamReader mySR = File.OpenText(s tr1);
// Gives an error 'illegal characters',
// whereas
StreamReader mySR = File.OpenText(s tr2);
// Works fine!!!
Both str1 and str2 look exactly the same when debugging.
Am I missing something or is this a known bug in C#?
Thanks,
Simon.
Can anyone explain the following behaviour?
private static int BUFFER_SIZE = 1024;
private byte [] Buffer = new byte[BUFFER_SIZE];
private Encoding ASCII = Encoding.ASCII;
private System.Net.Sock ets.Socket mySocket;
// Already accepted a connection...
int Length = mySocket.Receiv e(Buffer);
String str1 = ASCII.GetString (Buffer);
String str2 = ASCII.GetString (Buffer, 0, Length);
bool Same = (str1 == str2)
// Same is false!!!!!
// I only found this out because I was trying to open
// a file using str1 as the filename as follows...
StreamReader mySR = File.OpenText(s tr1);
// Gives an error 'illegal characters',
// whereas
StreamReader mySR = File.OpenText(s tr2);
// Works fine!!!
Both str1 and str2 look exactly the same when debugging.
Am I missing something or is this a known bug in C#?
Thanks,
Simon.
Comment