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. Remember - this is supposed to be C#...

Remember - this is supposed to be C#...

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharpperformancehelpquestiondiscussion
3 Posts 3 Posters 42 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.
  • 6 Offline
    6 Offline
    6oclock
    wrote on last edited by
    #1

    /// /// Fuegt solange Blanks an den String an, bis die /// Laenge length erreicht wird. /// /// /// /// public static string AddBlanks(string inputString, int length) { string outString = inputString; while (outString.Length < length) { outString = outString + " "; } return outString; } Not only a memory issue (using string instead of stringbuilder), but why have the gods^W BCL group created the string.PadRight(lenth, ' ') method? What do you think? :laugh: Cheers, Juergen

    J 1 Reply Last reply
    0
    • 6 6oclock

      /// /// Fuegt solange Blanks an den String an, bis die /// Laenge length erreicht wird. /// /// /// /// public static string AddBlanks(string inputString, int length) { string outString = inputString; while (outString.Length < length) { outString = outString + " "; } return outString; } Not only a memory issue (using string instead of stringbuilder), but why have the gods^W BCL group created the string.PadRight(lenth, ' ') method? What do you think? :laugh: Cheers, Juergen

      J Offline
      J Offline
      jhwurmbach
      wrote on last edited by
      #2

      6o`clock wrote:

      Not only a memory issue (using string instead of stringbuilder), but why have the gods^W BCL group created the string.PadRight(lenth, ' ') method? What do you think?

      I would think someone is learning C#. I can see me making mistakes of exactly the same type. Ok, I know about stringbuilder, but there are whole top-level namespaces I never used. I certainly do not know their functions by heart.


      Failure is not an option - it's built right in.

      E 1 Reply Last reply
      0
      • J jhwurmbach

        6o`clock wrote:

        Not only a memory issue (using string instead of stringbuilder), but why have the gods^W BCL group created the string.PadRight(lenth, ' ') method? What do you think?

        I would think someone is learning C#. I can see me making mistakes of exactly the same type. Ok, I know about stringbuilder, but there are whole top-level namespaces I never used. I certainly do not know their functions by heart.


        Failure is not an option - it's built right in.

        E Offline
        E Offline
        Erik Burger
        wrote on last edited by
        #3

        My colleague and I had an interesting discussion about this. According to us, there are two types of programmers out there. The first type thinks 'This is such a common thing to do, someone MUST have included it' and therefor ends up using the PadString method. The second type just churns away without seconds thoughts and ends up with the originally posted code. The funny thing is that 9 out of 10 times people tend to refactor these snippits into a utilities class, calling the method 'PadString' :cool:

        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