String Formatting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • J

    String Formatting

    I have a 512 character string and I need line breaks every few
    characters. What's a good way to do this in C#?
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: String Formatting

    J,

    I would use a string builder and break apart the string into the chunks
    that you need. Once you do that, cycle through the chunks, adding in the
    new line (Environment.Ne wLine) character(s) as needed.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "J" <jstroh@digipen .edu> wrote in message
    news:10e3d4ba.0 310281040.617d4 606@posting.goo gle.com...[color=blue]
    > I have a 512 character string and I need line breaks every few
    > characters. What's a good way to do this in C#?[/color]


    Comment

    • Tomo Ferega

      #3
      Re: String Formatting

      String "\r\n" represents newline in C#. You can use String.Insert property
      to insert in in specific place inside the string.

      - Huitzilopochtli

      "J" <jstroh@digipen .edu> wrote in message
      news:10e3d4ba.0 310281040.617d4 606@posting.goo gle.com...[color=blue]
      > I have a 512 character string and I need line breaks every few
      > characters. What's a good way to do this in C#?[/color]


      Comment

      Working...