Solved

Working with Strings

Posted on 2002-07-25
6
216 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
  • 5
6 Comments
 

Accepted Solution

by:
Aibras earned 100 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

772 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