473,406 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

NewLine Constant

If I have a "long" string variable which is a I break up into a multiline
value, I get a "Newline Constant" error in the compiler. If I make it all
a single line, then it has no problem.

In VB, you would use a "_" to create a continuation to the next line. I
did not think "C#" used a continuation character and that it looked for a
";" to terminate a line.

So why does it not like when I create a multiline variable?

Thanks in advance for your assistance!!!!!!
Nov 15 '05 #1
2 8294
You can either embed \n in your string or escape the string with a @ and
enter your newlines.
e.g.
private string whatever = @"This is the first line.
This is the second line.
This is the third line.";

or
private string whatever = "This is the first line.\nThis is the second
line.\nThis is the third line.";
"Jim Heavey" <Ji*******@nospam.com> wrote in message
news:Xn*********************************@207.46.24 8.16...
If I have a "long" string variable which is a I break up into a multiline
value, I get a "Newline Constant" error in the compiler. If I make it all
a single line, then it has no problem.

In VB, you would use a "_" to create a continuation to the next line. I
did not think "C#" used a continuation character and that it looked for a
";" to terminate a line.

So why does it not like when I create a multiline variable?

Thanks in advance for your assistance!!!!!!

Nov 15 '05 #2
Jim,
If I have a "long" string variable which is a I break up into a multiline
value, I get a "Newline Constant" error in the compiler. If I make it all
a single line, then it has no problem.

In VB, you would use a "_" to create a continuation to the next line. I
did not think "C#" used a continuation character and that it looked for a
";" to terminate a line.

So why does it not like when I create a multiline variable?


Try this:

System.String aVariable =
"This is line 1\n"
+ "This is line 2\n"
+ "This is line 3\n";

Does that help? I can't tell what your real problem is. You might want to
post the line of code that is causing the problem.

Regards,

Randy
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: shobhit.mathur | last post by:
Hi! I have a form with a textarea field. I want to validate the input from the textarea using javascript. Suppose I want to check that the user has not entered the string: "Hello World!" To...
6
by: 3strands | last post by:
Hi! I am writing a C++ program for a school project. It's a project and I could do it without this particualr feature, it's just it would be better if I could find out one thing: I'm making...
3
by: JJ | last post by:
Hi, I was wondering what is the constant for newline so that I can add newlines in messageBoxs ? Vb has vbcCrLf what is it for C#? Thanks, JJ
29
by: runningdog | last post by:
Hi, I would like to be able to embed a newline in a text string. Is there any convienent notation to do this TIA Steve
11
by: rossum | last post by:
I want to declare a const multi-line string inside a method, and I am having some problems using Environment.NewLine. I started out with: class foo { public void PrintStuff() { const...
18
by: Andrew Backer | last post by:
Is it possible to embed a newline constant in a string in the same way as c#? I really don't want to do something like this: ++ String.Format("Line 1 : {0} " & vbcrlf & " Line 2 : {1}", o, t)...
3
by: dcwbxb | last post by:
Trying to create a program which reads and echos the contents of an input data file, which consists of two records. When I complile my code I keep getting a "error C2001: newline in constant" error....
2
by: jehugaleahsa | last post by:
Hello: I am reading a rather oddly formatted file being sent to us by an outside source. I am wondering if there is a way to change what StreamReader sees as a newline. It is searching for a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.