Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 598099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:21:08+00:00 2026-05-13T16:21:08+00:00

I have a class with a member Address that I read from an XML

  • 0

I have a class with a member “Address” that I read from an XML file that has the following format(fake address – The XML field name is “Address” – not shown):

106-1190 Crescent St. \r\n Toronto Ont \r\n V2K 2Z6

I have created a Multi-Line Textbox to display in a form with the Accepts-Return property set to true.

The Textbox displays the following with the new-line characters not working

106-1190 Crescent St. \r\n Toronto Ont \r\n V2K 2Z6

I’ve looked online for various solutions and I have tried the following:

1) \n and \\n

2) \\r\\n

It works if I add to the property directly like so:

Address.Text = "106-1190 Crescent St.\r\nToronto Ont\r\nV2K 2Z6";

But if I load a string variable from an XML file and try to assign it to the Text property:

Address.Text = Employee.Address;

It does not work.

I set watch points to check the difference between the direct assignment and the variable assignment ang got this difference:

Direct: 106-1190 Crescent St. \r\n Toronto Ont \r\n V2K 2Z6

Variable: 106-1190 Crescent St. \\r\\n Toronto Ont \\r\\n V2K 2Z6

so somewhere the code is changing the backslash to a double backslash in converting from the XML string to the variable.

I don’t really want to have to parse my XML strings to remove the extra slash….
How do I represent my string data in an XML file such that it gets converted to a proper string variable with just the single slash, in order for my line breaks to show up properly.

Thanks in advance.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:21:08+00:00Added an answer on May 13, 2026 at 4:21 pm

    The textbox control doesn’t interpret escapes and neither does XML. so this is just the characters \ r and n. You need to process the string, substituting the string @”\r\n” for “\r\n”.

    Address.Text = Employee.Address.Replace(@"\r\n", "\r\n");
    

    this is the equivalent to this

    Address.Text = Employee.Address.Replace("\\r\\n", "\r\n");
    

    because @ prevents interpreting of \ in the string.

    edit: based on a comment, this is even better form, it translates to \n on unix, and \r\n on Windows.

    Address.Text = Employee.Address.Replace("\\r\\n", Environment.NewLine);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a class that has a protected pointer member of the following
I have a class that has several member classes as attributes. The constructor of
I have a class that has a vector member variable, which I fill up
I have a virtual class that has been derived from a non virtual class.
I have a class that had an inline member, but I later decided that
I have the following class: public class Address { public virtual int Id {
I have a class, C. C has a member variable declared as: bool markerStart;
Hello I have a pump class that requires using a member variable that is
Say I have a class definition: class CustomClass { int member; }; Why is
I have simple class with width and height member fields which define number of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.