?
Solved

Working with Strings

Posted on 2002-07-25
6
Medium Priority
?
230 Views
Last Modified: 2010-04-15
This should be an easy question.

I am trying to append a carriage return and line feed between two strings.  

string s1 = "line 1 of text";
string s2 = "line 2 of text";
string s3 = s1 + "(line feed carrige return)" + s2;

I want there to be a carriage return and line feed between s1 and s2 so I can then use ReadLine() to read each line of the string.  I tried using /r and /n between the strings, but then ReadLine() does not work.  It reads the entire string as one line.  This should be an easy question to answer.  I looked around, but I could not find any examples.

Thanks in advance.


0
Comment
Question by:sdn421
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
6 Comments
 

Accepted Solution

by:
Aibras earned 400 total points
ID: 7177891
you can use "\n" new line not /n :)

try this code

-------------

          static void Main()
          {
               string s1 = "experts";
               string s2 = "exchange";
               string s3 = s1 + "\n" + s2;
                        // "\n" New line
               Console.Write(s3);

          }

-----------------------------
0
 
LVL 1

Author Comment

by:sdn421
ID: 7177957
No wonder it did not work.  I was using / instead of \...DUH!  Thanks for your help.
0
 
LVL 1

Author Comment

by:sdn421
ID: 7177958
No wonder it did not work.  I was using / instead of \...DUH!  Thanks for your help.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:sdn421
ID: 7177970
No wonder it did not work.  I was using / instead of \...DUH!  Thanks for your help.
0
 
LVL 1

Author Comment

by:sdn421
ID: 7177974
Aibras,

Let me know if your answer gets accepted.  I keep getting an error when I try to accept it.
0
 
LVL 1

Author Comment

by:sdn421
ID: 7178359
Aibras,

It still will not let me accept your answer so I posted the problem in the support forum.  Thanks for you help again.

http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20328025
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question