Quick, newbie question: Multiple line string

This is a discussion on Quick, newbie question: Multiple line string within the C# Programming forums, part of the General Programming Boards category; Did a quick search for this but didn't seem to come up with anything relative. I'm sure there's some simple ...

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    16

    Quick, newbie question: Multiple line string

    Did a quick search for this but didn't seem to come up with anything relative. I'm sure there's some simple solution for this but I can't seem to find it, grr.

    How do I make this statement work (eg. think it's all on one line)? I know I could put it all on one manually but that's ugly.

    Code:
                string Data =
                    "<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"
                    "   <s:Body>\n"
                    "      <u:SetAudioInputName xmlns:u="urn:schemas-upnp-org:service:AudioIn:1">\n"
                    "         <DesiredName>" , textBoxName.Text , "</DesiredName>\n"
                    "      </u:SetAudioInputName>\n"
                    "   </s:Body>\n"
                    "</s:Envelope>";

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    You can concatinate strings with + if that's what you are looking for. Add a + before each new line.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Banned nickname_changed's Avatar
    Join Date
    Feb 2003
    Location
    Australia
    Posts
    986
    Or you can do:
    Code:
                string Data =
                   @ "<s:Envelope s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">
                      <s:Body>
                        <u:SetAudioInputName xmlns:u="urn:schemas-upnp-org:service:AudioIn:1">
                           <DesiredName>" +  textBoxName.Text  + @"</DesiredName>
                         </u:SetAudioInputName>
                      </s:Body>
                   </s:Envelope>";
    Note the @ in front of the multi-line strings, and the + operator to add strings to variables.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quick Newbie String Help
    By JaydinBane in forum C Programming
    Replies: 2
    Last Post: 02-24-2009, 03:01 AM
  2. String Class
    By BKurosawa in forum C++ Programming
    Replies: 117
    Last Post: 08-09-2007, 02:02 AM
  3. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 01:56 PM
  4. Question about parsing a string from a line
    By edd1986 in forum C Programming
    Replies: 2
    Last Post: 04-23-2005, 04:18 PM
  5. ........ed off at functions
    By Klinerr1 in forum C++ Programming
    Replies: 8
    Last Post: 07-29-2002, 10:37 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21