Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vbCrLF or Environment.NewLine

Tags:

vb.net

I use Environment.NewLine, my colleagues use vbCrLf.

When I'm doing a code review for them I want something that I can point to to say "use Environment.NewLine instead of vbCrLf"

Or, am I just peeing in the wind, and it doesn't really matter ?

like image 759
cometbill Avatar asked Jan 19 '12 17:01

cometbill


2 Answers

Environment.NewLine is more portable, making to code easier to be read by someone coding in C#. Technically vbCrLf is a constant, where NewLine is not. This is because on a different OS, NewLine may not return CR/LF. On Unix it would just be LF.

like image 132
tcarvin Avatar answered Nov 15 '22 10:11

tcarvin


Another point is that Environment.NewLine expresses the intended meaning more clearly. In most cases, the goal is Place a newline in this string, not Place carriage-return and line-feed characters in this string. Environment.NewLine states what to do, vbCrlf states how to do it.

like image 22
Daniel Neel Avatar answered Nov 15 '22 11:11

Daniel Neel