Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

Working with Strings

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
sdn421
Asked:
sdn421
  • 5
1 Solution
 
AibrasCommented:
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
 
sdn421Author Commented:
No wonder it did not work.  I was using / instead of \...DUH!  Thanks for your help.
0
 
sdn421Author Commented:
No wonder it did not work.  I was using / instead of \...DUH!  Thanks for your help.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
sdn421Author Commented:
No wonder it did not work.  I was using / instead of \...DUH!  Thanks for your help.
0
 
sdn421Author Commented:
Aibras,

Let me know if your answer gets accepted.  I keep getting an error when I try to accept it.
0
 
sdn421Author Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now