String question

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

    #1

    String question

    Hi!

    Completely dumb question...

    I'm constructing email text in code and need to add line break.

    i.e.:

    s = "sdfsd" + LineBreak + "sdfsdf";

    In VB I use vbNewLine

    How do I make it in C#?

    Thanks!


  • Tobin Harris

    #2
    Re: String question

    "Ivan Demkovitch" <i@a.b> wrote in message
    news:uqULBp0lDH A.3504@TK2MSFTN GP11.phx.gbl...[color=blue]
    > How do I make it in C#?[/color]

    string s = "line1\nlin e2"
    Tobes
    [color=blue]
    > Thanks!
    >
    >[/color]


    Comment

    • Daniel Pratt

      #3
      Re: String question

      Hi Ivan,

      Use "\r\n". That is:

      s = "sdfsd\r\nsdfsd f";

      Regards,
      Dan

      "Ivan Demkovitch" <i@a.b> wrote in message
      news:uqULBp0lDH A.3504@TK2MSFTN GP11.phx.gbl...[color=blue]
      > Hi!
      >
      > Completely dumb question...
      >
      > I'm constructing email text in code and need to add line break.
      >
      > i.e.:
      >
      > s = "sdfsd" + LineBreak + "sdfsdf";
      >
      > In VB I use vbNewLine
      >
      > How do I make it in C#?
      >
      > Thanks!
      >
      >[/color]


      Comment

      • Ivan Demkovitch

        #4
        Re: String question

        Ok...

        Now I want to know what is the difference between \n and \r\n ???

        Thanks!


        Comment

        • Peter Rilling

          #5
          Re: String question

          A better way might be to use the Environment.New Line property.

          They just map to control characters, "\n" = newline and "\r" = carriage
          return.

          The difference, I believe, is that the newline moves the cursor vertically
          one row. The horizontal position stays the same. The carriage return moves
          the cursor to the beginning of the row that it is currently one.

          Although the need for these have probably gone away, they are a carry-over
          from the old dos environment in which these characters would give you
          control over the cursors position.

          "Ivan Demkovitch" <i@a.b> wrote in message
          news:OuaY0P1lDH A.1764@tk2msftn gp13.phx.gbl...[color=blue]
          > Ok...
          >
          > Now I want to know what is the difference between \n and \r\n ???
          >
          > Thanks!
          >
          >[/color]


          Comment

          • Girish Bharadwaj

            #6
            Re: String question

            Ivan Demkovitch wrote:
            [color=blue]
            > Ok...
            >
            > Now I want to know what is the difference between \n and \r\n ???
            >
            > Thanks!
            >
            >[/color]
            Nothing much except that Windows goes for "\r\n" as end of line char,
            "\n" is the endof line in Unix/Linux like env, "\n\r" (I think) is the
            end of line in Mac..
            :)

            --
            Girish Bharadwaj

            Comment

            Working...