VB.Net chr() equivalent in C#.net

  • Thread starter Thread starter Vasanth
  • Start date Start date
V

Vasanth

Hi Techies,

Could you please let me know the equivalent of VB.Net chr() in C#.net?

Regards,
Vasanth
 
Vasanth said:
Hi Techies,

Could you please let me know the equivalent of VB.Net chr() in C#.net?

If you're looking to generate the "normal" ASCII keycodes, e.g. A-Z, 0-9
etc, then the C# equivalent of the VB.Net Chr(65) is (char)65. However, if
you're looking for the other characters e.g. escape sequences, CrLf etc, you
need to use things like \n, \r etc.

The following site should be of help to you:

http://www.harding.edu/USER/fmccown/WWW/vbnet_csharp_comparison.html
 
John Wood said:
fyi the framework provides Environment.NewLine constant for the \n\r escape
sequence.

Other way round - "\r\n". However, that's not what it's *defined* to be
- it's defined to be the default line separate for the platform. That
means that on Mono it's (I would imagine) "\r\n" for Windows and "\n"
for Linux, for example.

In my view, it should only be used when writing text files to be read
on that platform - if you're trying to conform to a protocol which
specifies which line separator to use, you should use that exact string
rather than Environment.NewLine.
 
Other way round - "\r\n".
You're just here to point out my typos aren't you.
In my view, it should only be used when writing text files to be read
on that platform - if you're trying to conform to a protocol which
specifies which line separator to use, you should use that exact string
rather than Environment.NewLine.

So, here's a question for you, does StreamWriter::WriteLine use
Environment.NewLine or \r\n?
 
John Wood said:
You're just here to point out my typos aren't you.

LOL. I thought I'd mention it in passing :)
So, here's a question for you, does StreamWriter::WriteLine use
Environment.NewLine or \r\n?

According to the docs, it defaults to "\r\n" - but you can change it
using the TextWriter.NewLine property.
 

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

Back
Top