equivalent of vbCrLf in c#
C#ListSplitLanguage ComparisonsC# 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
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"