Share via


Is there a C# equivalent to vbCrLF and vbTab

Question

Friday, May 14, 2004 1:50 PM

All-- Is there a C# equivalent to vbCrLF and vbTab? I know that we can use C# escape sequences, such as... vbTab >>>> \t ...but, what would really be nice is if we had in C# a kind of ControlChars class that maps to "friendly identifier", the same way we have in VB.NET and "vbTab". Any ideas? Please advise. Thank you. --Mark

All replies (12)

Friday, May 14, 2004 4:43 PM ✅Answered

System.Environment.NewLine There is no equivalent for the horizontal tab.


Saturday, May 15, 2004 7:58 AM ✅Answered

A string containing "\r\n". you can create your own constants if necessary to make them "vbCrLf", but I'm comfortable seeing \r\n


Monday, February 12, 2007 12:01 AM ✅Answered

All-- Is there a C# equivalent to vbCrLF and vbTab? I know that we can use C# escape sequences, such as... vbTab >>>> \t ...but, what would really be nice is if we had in C# a kind of ControlChars class that maps to "friendly identifier", the same way we have in VB.NET and "vbTab". Any ideas? Please advise. Thank you. --Mark

I'm surprised no-one else said it, but you do have a "kind of ControlChars class". It's called ControlChars and can be found in the Microsoft.VisualBasic namespace. Of course, you'll need to add a reference to the microsoft.visualbasic.dll assembly, but who cares? It's going to be installed on the box anyway.

Remember that as a C# developer you have access to a lot of "VB specific" stuff just by adding a reference to the VB assemblies. It's not always recommended, but if you want to, you're welcome to use them.

 


Friday, February 9, 2007 11:40 AM

System.Environment.NewLine There is no equivalent for the horizontal tab.

When I tried:

using System.Enviroment.NewLine;

After the System, the Enviroment is not one the options showing in the Intellisense. I'm using C#.


Friday, February 9, 2007 1:06 PM

Try: Enviro**n**ment


Friday, February 9, 2007 1:17 PM

Thanks for the response. It's not the spelling. I spelled it here wrong but not in the code.


Friday, February 9, 2007 1:26 PM

System.Environment.NewLine There is no equivalent for the horizontal tab.

When I tried:

using System.Enviroment.NewLine;

After the System, the Enviroment is not one the options showing in the Intellisense. I'm using C#.

You did not get it because in C# they are collectively called literals.  Try the link below for details.

http://www.yoda.arachsys.com/csharp/strings.html


Friday, February 9, 2007 2:35 PM

Thank so much. I got it. Environment.Newline works now.


Friday, February 9, 2007 2:40 PM

Thank so much. I got it. Environment.Newline works now.

I am glad I could help.


Monday, February 12, 2007 8:46 AM

Much appreciated for the additional information. Why is it not always recommended?


Monday, February 12, 2007 9:08 AM

One reason I can think of is maintenance.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

 <o:p></o:p>

If you avoid VB specific stuff, a C# programmer can more easily maintain your code. Both languages have equivalent constructs (if, else, do while, etc.).


Monday, February 12, 2007 12:21 PM

The 'Financial' module of the Microsoft.VisualBasic namespace is especially useful to know about.  There is no equivalent in the rest of the framework for this.