-
strings and sockets
i have a client server program
the client gets a username and then converts it to a unicode byte array with it then sends throguth a socket
at the server side it
converts the bite array back to a unicode string
then compares it with the structure of usernames, but it always failes
when looking at both strings in the watch window both apper identical, however when i check the lenght one is 5 one is 128.
i have tried trimming the string but i still cannot get rid of the extra stuff
how do i do it??
-
cast it to a string using .ToString() on the server when it recieves it..
that might work
-
i tried the tostring on the byte array, but when i view the string it says: "System.Byte[]" :(
-
did you do ToString() on the object type? or the actual string?
it seems like you did the type not the actual string
for example if i have a array of chars
i would do
string myString = "";
foreach(char ch in arrOfChars)
{
myString += ch.ToString(); //this will convert the char to string then append it to a string so u get literal values
}
try the samething iwth yoru byte array
then whe ur done.
compare myString with what ever u need to compare from the server to determine if the user name was correct