Question

What is the equivalent of C#'s \n and Visual Basic's vbCRLF or vbNewLine in Delphi Prism? Do I have to use Environment.NewLine?

Was it helpful?

Solution

Environment.NewLine is actually the best thing to use, as it is supposed to be platform independent. This guidance goes for C# as well, by the way.

OTHER TIPS

MyString := 'One'#13#10'Two'; would be the equivalent of c#'s "One\r\nTwo".

The appropriate new line character is not a question of runtime platform or language choice, it is a question of the source (or intended recipient) of the output file. If the file is entirely for private use by an application (only ever read/written by the app) then you can use whatever character you like to delimit lines.

If you need to exchange the file with some party or process outside of the application itself then the needs of that other party may well dictate what you should expect (and are expected) to use as the new line character.

To answer the actual question as put however, the equivalent of vbCRLF is (as a literal value) #13#10 and the equivalent of vbNewLine would be #10 (#13 is the char code for CR and #10 for LF).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top