What is vbCrLf counterpart in C#

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, friends,

In VB, there is a vbCrLf for a new line. What is the counterpart in C#?
Thanks.
 
There is a .NET counterpart: System.Environment.NewLine
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter
Clear VB: Cleans up outdated VB.NET code
 
Mythran said:
Environment.NewLine

No - there's a subtle difference there. Environment.NewLine won't
always give you carriage-return-line-feed which I would certainly hope
that vbCrLf will. Instead, it gives you the default newline for the
current system - which on windows is \r\n, but not on some other
platforms (where you might be running Mono or Rotor).

It's always worth making sure you know exactly which one you actually
want - if you're writing text files, Environment.NewLine is probably
correct. If you're dealing with a network protocol which specifies the
line terminator, you should use that.
 
Jon Skeet said:
No - there's a subtle difference there. Environment.NewLine won't
always give you carriage-return-line-feed which I would certainly hope
that vbCrLf will. Instead, it gives you the default newline for the
current system - which on windows is \r\n, but not on some other
platforms (where you might be running Mono or Rotor).

It's always worth making sure you know exactly which one you actually
want - if you're writing text files, Environment.NewLine is probably
correct. If you're dealing with a network protocol which specifies the
line terminator, you should use that.

Yeah, I was going to reply to myself and correct my post, but someone else
already posted it :)

Thanks,
Mythran
 

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