equivalent of vbCrLf in c#

C#ListSplitLanguage Comparisons

C# Problem Overview


I have a to do this:

AccountList.Split(vbCrLf)

In c# AccountList is a string. How can i do?

thanks

C# Solutions


Solution 1 - C#

You are looking for System.Environment.NewLine.

On Windows, this is equivalent to \r\n though it could be different under another .NET implementation, such as Mono on Linux, for example.

Solution 2 - C#

I typically abbreviate so that I can use several places in my code. Near the top, do something like this:

 string nl = System.Environment.NewLine;

Then I can just use "nl" instead of the full qualification everywhere when constructing strings.

Solution 3 - C#

AccountList.Split("\r\n");

Solution 4 - C#

Add a reference to Microsoft.VisualBasic to your project.

Then insert the using statement

using Microsoft.VisualBasic;

Use the defined constant vbCrLf:

private const string myString = "abc" + Constants.vbCrLf;

Solution 5 - C#

Are you looking for

System.Environment.NewLine

Solution 6 - C#

I think that "\r\n" should work fine

Solution 7 - C#

try this:

AccountList.Split(new String[]{"\r\n"},System.StringSplitOptions.None);

or

AccountList.Split(new String[]{"\r\n"},System.StringSplitOptions.RemoveEmptyEntries);

Solution 8 - C#

There is no equivalent of vbCrLf constant in C#. C#'s System.Environment.NewLine is an equivalent of vbNewLine in Visual Basic, it's NOT an equivalent of vbCrLf, because the value System.Environment.NewLine depends on OS where the C# application is running (and so does vbNewLine) - see msdn link as a reference.

In C# you can use "\r\n" instead of vbCrLf, as already was mentioned in one of the comments.

Solution 9 - C#

"FirstLine" + "<br/>" "SecondLine"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLuca RomagnoliView Question on Stackoverflow
Solution 1 - C#DavidView Answer on Stackoverflow
Solution 2 - C#Neil NView Answer on Stackoverflow
Solution 3 - C#Justin NiessnerView Answer on Stackoverflow
Solution 4 - C#huhaView Answer on Stackoverflow
Solution 5 - C#Adriaan StanderView Answer on Stackoverflow
Solution 6 - C#JavierView Answer on Stackoverflow
Solution 7 - C#Santosh SharmaView Answer on Stackoverflow
Solution 8 - C#victorm1710View Answer on Stackoverflow
Solution 9 - C#Kreshnik KuqiView Answer on Stackoverflow