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. Other Discussions
  3. The Weird and The Wonderful
  4. Why use String.Concat() ?

Why use String.Concat() ?

Scheduled Pinned Locked Moved The Weird and The Wonderful
question
7 Posts 6 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.
  • C Offline
    C Offline
    CoperNick
    wrote on last edited by
    #1

    value = String.Concat(value, intValue.ToString(), ".");

    logBuilder = String.Concat("some long text",
    "some long text. ");

    String errorMessage = String.Concat("Long text, exception: ", ex.ToString());

    Find all "String.Concat", Subfolders, Find Results 1, "Current Project" ... Matching lines: 297 Matching files: 32 Total files searched: 106

    C F K 3 Replies Last reply
    0
    • C CoperNick

      value = String.Concat(value, intValue.ToString(), ".");

      logBuilder = String.Concat("some long text",
      "some long text. ");

      String errorMessage = String.Concat("Long text, exception: ", ex.ToString());

      Find all "String.Concat", Subfolders, Find Results 1, "Current Project" ... Matching lines: 297 Matching files: 32 Total files searched: 106

      C Offline
      C Offline
      CoperNick
      wrote on last edited by
      #2

      And this is the best:

      String errorMessage = String.Concat(".... packet is fail, exception: ", ex.ToString());
      SomeClass.someMember.Error(String.Concat(errorMessage));

      S L 2 Replies Last reply
      0
      • C CoperNick

        And this is the best:

        String errorMessage = String.Concat(".... packet is fail, exception: ", ex.ToString());
        SomeClass.someMember.Error(String.Concat(errorMessage));

        S Offline
        S Offline
        StM0n
        wrote on last edited by
        #3

        String.Concat("Someone has fallen in love with", "String.Concat");

        (yes|no|maybe)*

        1 Reply Last reply
        0
        • C CoperNick

          And this is the best:

          String errorMessage = String.Concat(".... packet is fail, exception: ", ex.ToString());
          SomeClass.someMember.Error(String.Concat(errorMessage));

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

          I think I have spotted this coder in the wild! http://stackoverflow.com/questions/11032394/substring-not-working-as-expected-if-length-greater-than-length-of-string[^] :laugh:

          IronScheme
          ((λ (x) `(,x ',x)) '(λ (x) `(,x ',x)))

          B 1 Reply Last reply
          0
          • L leppie

            I think I have spotted this coder in the wild! http://stackoverflow.com/questions/11032394/substring-not-working-as-expected-if-length-greater-than-length-of-string[^] :laugh:

            IronScheme
            ((λ (x) `(,x ',x)) '(λ (x) `(,x ',x)))

            B Offline
            B Offline
            Brisingr Aerowing
            wrote on last edited by
            #5

            That has to be him! :laugh:

            public class SysAdmin : Employee
            {

             public override void DoWork(IWorkItem workItem)
             {
                  if (workItem.User.Type == UserType.NoLearn){
                     throw new NoIWillNotFixYourComputerException(new Luser(workItem.User));
                  }else{
                       base.DoWork(workItem);
                  }
             }
            

            }

            1 Reply Last reply
            0
            • C CoperNick

              value = String.Concat(value, intValue.ToString(), ".");

              logBuilder = String.Concat("some long text",
              "some long text. ");

              String errorMessage = String.Concat("Long text, exception: ", ex.ToString());

              Find all "String.Concat", Subfolders, Find Results 1, "Current Project" ... Matching lines: 297 Matching files: 32 Total files searched: 106

              F Offline
              F Offline
              FireDog31262
              wrote on last edited by
              #6

              This is just as bad as my example of String.Format. :doh: :wtf:

              No matter where you go, there you are...~?~

              1 Reply Last reply
              0
              • C CoperNick

                value = String.Concat(value, intValue.ToString(), ".");

                logBuilder = String.Concat("some long text",
                "some long text. ");

                String errorMessage = String.Concat("Long text, exception: ", ex.ToString());

                Find all "String.Concat", Subfolders, Find Results 1, "Current Project" ... Matching lines: 297 Matching files: 32 Total files searched: 106

                K Offline
                K Offline
                KP Lee
                wrote on last edited by
                #7

                If you've read anything about strings, you must have read that you should use StringBuilder instead. "some text" + "some more" + " text" is expensive. I would guess Concat gives you a performance boost similar to StringBuilder, but limited to strings. I have to admit that appending each value individually in builder is bothersome. I know I wanted to find out how much builder helps, so I built a cpu intensive process with accounting numbers. I mixed fixed text with numbers to a string using + logic. Got the actual coding to work and changed over to StringBuilder. Processing went from 40 minutes to 20 minutes. Then I changed the logic to only use builder when I needed to save the stat strings. Cut down to 7 minutes. Then played with the process order and it went to 4 minutes. Needed to buy my second laptop in 7 years to cut it to 2 minutes. :)

                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