StreamWriter problem

Z

zon7

Hi, I'm trying to make a chat program, but it seems to have some kind
of problem with the some characters. To be more precise, the only
characters giving me problem are "{" and "}".
When I try to send them with
stream.Write(A,0,A.Length);
where A is a String
it tells me that there is a incorrect character.
Any help?
 
N

nick_nw

zon7 said:
Hi, I'm trying to make a chat program, but it seems to have some kind
of problem with the some characters. To be more precise, the only
characters giving me problem are "{" and "}".
When I try to send them with
stream.Write(A,0,A.Length);
where A is a String
it tells me that there is a incorrect character.
Any help?

There isn't an overloaded method for StreamWriter.Write that takes the
string to be written, start index, and length. The method you are
trying to call is Write (string, object, object) as described here
http://msdn2.microsoft.com/en-us/library/fd857wct.aspx.

If you want to write the string as an array of chars then you could use
this call:

stream.Write (A.ToCharArray (), 0, A.ToCharArray ().Length);

Or if you just want to write the string then call:

stream.Write (A);

Let me know if this helps,

Nick
http://seecharp.blogspot.com/
 
J

Jon Skeet [C# MVP]

zon7 said:
Hi, I'm trying to make a chat program, but it seems to have some kind
of problem with the some characters. To be more precise, the only
characters giving me problem are "{" and "}".
When I try to send them with
stream.Write(A,0,A.Length);
where A is a String
it tells me that there is a incorrect character.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 

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