Re: \n?? \r??

From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 09/17/04


Date: Fri, 17 Sep 2004 13:31:57 +0100

Drebin <thedrebin@hotmail.com> wrote:
> I've seen it in countless MS docs and on countless MS blogs and
> newsgroups... Why isn't it proper?

Because it depends on whether you *actually* want it to be dependent on
your environment. For instance, many protocols specify that the newline
in the protocol *must* be "\r\n" - which isn't necessarily the value of
Environment.NewLine. (It is on the MS CLR, but it may not be on Mono,
for instance.)

Environment.NewLine does precisely what it says in the docs: "Gets the
newline string defined for this environment." In many situations you
want the newline string defined for a particular protocol. Even if that
happens to be the same on the environment you're running in, it's
better to make it explicit so that when you're running in an
environment where Environment.NewLine may return something different,
your code doesn't break.

-- 
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Relevant Pages

  • Cisco IP Phone H.323 with Avaya IP Office
    ... I would like to know if anyone else has never tested this environment ... IP Office should support H.323 protocol V2, negotiation and ...
    (comp.dcom.sys.cisco)
  • Re: Remoting and Robotics
    ... I think a connection based protocol will ... With a connection based protocol you will often ... I'm developing a remote control panel for a mobile robot I'm developing. ... Also make the other usual assumptions of a robotic environment vs. a ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: new routing protocol
    ... > I am in the process of implementing a routing protocol under 5.0. ... I thought about kernel modules, but I don't know what kind to use ... your protocol in userland on top of that environment, ... - a very fast turnaround compile/test time ...
    (freebsd-hackers)
  • Re: PS/2 Mouse Problem!
    ... Kaveh Gh wrote: ... >ImPS/2. ... In X environment, ... which kind of protocol I have to test? ...
    (Debian-User)