Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Beginner Q - long strings

Beginner Q - long strings

Scheduled Pinned Locked Moved C#
learningcsharpc++comtutorial
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alexandru Savescu
    wrote on last edited by
    #1

    Hello, I am working on my first project on C# after coming from C++ and I cannot seem to find out how to write long strings on multiple lines. It seems like

    string longstr = "aaaa"
    "bbbb";

    or

    string longstr = "aaaa \
    bbbb";

    do not work. Of course I can use the + operator, but I don't want to introduce an extra overhead. Thanks! Best regards, Alexandru Savescu P.S. Interested in art? Visit this!

    L 1 Reply Last reply
    0
    • A Alexandru Savescu

      Hello, I am working on my first project on C# after coming from C++ and I cannot seem to find out how to write long strings on multiple lines. It seems like

      string longstr = "aaaa"
      "bbbb";

      or

      string longstr = "aaaa \
      bbbb";

      do not work. Of course I can use the + operator, but I don't want to introduce an extra overhead. Thanks! Best regards, Alexandru Savescu P.S. Interested in art? Visit this!

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      string longstr = @"aaaa

                     bbbb";
      

      :) MyDUMeter: a .NET DUMeter clone
      "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."

      A 2 Replies Last reply
      0
      • L leppie

        string longstr = @"aaaa

                       bbbb";
        

        :) MyDUMeter: a .NET DUMeter clone
        "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."

        A Offline
        A Offline
        Alexandru Savescu
        wrote on last edited by
        #3

        Thanks! ;) Best regards, Alexandru Savescu P.S. Interested in art? Visit this!

        1 Reply Last reply
        0
        • L leppie

          string longstr = @"aaaa

                         bbbb";
          

          :) MyDUMeter: a .NET DUMeter clone
          "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."

          A Offline
          A Offline
          Alexandru Savescu
          wrote on last edited by
          #4

          Me again! I tried your solution and of course it works, but when I take a look at the string in the debugger I am not satisfied with what I see. It semmes like my string contains lots of spaces between the last a and the first b. I didn't mean that, all I want is a way the compiler can concatenate my strings.... Best regards, Alexandru Savescu P.S. Interested in art? Visit this!

          L 1 Reply Last reply
          0
          • A Alexandru Savescu

            Me again! I tried your solution and of course it works, but when I take a look at the string in the debugger I am not satisfied with what I see. It semmes like my string contains lots of spaces between the last a and the first b. I didn't mean that, all I want is a way the compiler can concatenate my strings.... Best regards, Alexandru Savescu P.S. Interested in art? Visit this!

            L Offline
            L Offline
            leppie
            wrote on last edited by
            #5

            OK you have this then:

            string longstr = "jsandjksajdhakhdkajshd" +
            "asmndjashdkashdhaskdhk" +
            "asmndjashdkashdhaskdhk" +
            "asmndjashdkashdhaskdhk" +
            "asmndjashdkashdhaskdhk".
            ToString(); //just to show freeform, never neccesary

            Remember C# is freeform. :) I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups