V
Vai2000
In VC++ if wanted to break a string on line I can use this
\n"
What's the equivalent in C#?
TIA
\n"
What's the equivalent in C#?
TIA
Vai2000 said:In VC++ if wanted to break a string on line I can use this
\n"
What's the equivalent in C#?
Vai2000 said:In VC++ if wanted to break a string on line I can use this
\n"
What's the equivalent in C#?
Try Environment.NewLineVai2000 said:In VC++ if wanted to break a string on line I can use this
\n"
What's the equivalent in C#?
TIA
System.Environment.NewLine. Typically this has the value \r\n.
C# recognizes the C character escapes \r and \n and they have the same
character equivalence that they have in C.
Agreed.
C# in general does NOT follow
the C convention that a single \n indicates a line break
and on output
(e.g. to a file or to the console), .NET will NOT convert \n to \r\n as C
typically does when running on Windows.
Vai2000 said:sorry for poorly explaining in vb you can break a string by _ to the next
line
the quick brown _
fox jumps over the _
lazy dog
I am looking for equivalent of _ in c#
Jon said:Carl Daniel [VC++ MVP]
System.Environment.NewLine. Typically this has the value \r\n.
C# recognizes the C character escapes \r and \n and they have the
same character equivalence that they have in C.
Agreed.
C# in general does NOT follow
the C convention that a single \n indicates a line break
I wouldn't say that's a C convention particuarly - it's entirely
context sensitive. When writing to the console, at least on the build
of XP I'm running, \n is enough. It's not in a TextBox - on Windows.
and on output
(e.g. to a file or to the console), .NET will NOT convert \n to \r\n
as C typically does when running on Windows.
Yes - although again, that's the behaviour of *libraries* rather than
the language itself. As far as I'm aware, the C compiler itself won't
do any conversion of \n to \r\n.
(I know I'm being picky, but it can be important to realise the
boundary between language and library.)
Vai2000 said:sorry for poorly explaining in vb you can break a string by _ to the next
line
the quick brown _
fox jumps over the _
lazy dog
I am looking for equivalent of _ in c#
Carl said:Picky yes, but correct - it's the CRT that does the conversion for C/C++
programs on windows. Confuses way more programmers than it ever helped,
IMO. Preserved for decades of backwards compatibility with the earliest of
DOS-based C compilers.
Arne said:No. Done because that is what C/C++ does.
Arne said:Carl said:Jon Skeet [C# MVP] wrote:
Yes - although again, that's the behaviour of *libraries* rather
than the language itself. As far as I'm aware, the C compiler itself
won't do any conversion of \n to \r\n.
(I know I'm being picky, but it can be important to realise the
boundary between language and library.)
Picky yes, but correct - it's the CRT that does the conversion for
C/C++ programs on windows. Confuses way more programmers than it
ever helped, IMO. Preserved for decades of backwards compatibility
with the earliest of DOS-based C compilers.
No. Done because that is what C/C++ does.
It's the C/C++ runtime library that we're talking about here. The reasons
for the \r\n to \n conversion are entirely historical and not the least
technical. Had the first implementations of C on DOS stored text files with
only linefeeds as separators, then that's what VC++ would do today.
It's the C/C++ runtime library that we're talking about here. The reasons
for the \r\n to \n conversion are entirely historical and not the least
technical. Had the first implementations of C on DOS stored text files with
only linefeeds as separators, then that's what VC++ would do today.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.