Hi!

I want to join 2 strings, but it has been impossible.
I have this:

i = socket.Receive(buffer);
 recibido = System.Text.Encoding.UTF8.GetString(buffer)

Buffer contains: "C:"

I want to add the "\\" to the string so i have tried to do:

recibido = recibido + "\\".

But no way, when y print the result it shows again "C:"
I have also tried using StringBuilder:
http://msdn.microsoft.com/en-us/library/ms228504(v=vs.80).aspx

But is the same it just print "C:"

I ve also tried changing the "\\" for any other thing like "hello"... and it still shows "C:".

Recommended Answers

All 4 Replies

>I want to join 2 strings, but it has been impossible.

What is the size of buffer (length of buffer array)?

string str = System.Text.Encoding.UTF8.GetString(buffer,0,2) + "\\";

You were right.
The problem is that i ve benn using "System.Text.Encoding.UTF8.GetString" without the to parameters "0" and "2". For what are they ?

Please read MSDN documentation.

System.Text.Encoding.UTF8.GetString(byteArray,offset,Length)

Thanks, i searched in google before making the question but i didnt find anything.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.