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. stringbuilder to string

stringbuilder to string

Scheduled Pinned Locked Moved C#
tutorialquestion
8 Posts 5 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.
  • M Offline
    M Offline
    michaelgr1
    wrote on last edited by
    #1

    Hello, When i am trying to copy stringbuilder to string it copies the same string twice or 3 times for example if i do: stringbuilder temp=new stringbuilder(); string temp1; temp1=temp.tostring(); if temp="abc"; then temp1 gets- "abcabcabc" why is that?

    R L N realJSOPR 4 Replies Last reply
    0
    • M michaelgr1

      Hello, When i am trying to copy stringbuilder to string it copies the same string twice or 3 times for example if i do: stringbuilder temp=new stringbuilder(); string temp1; temp1=temp.tostring(); if temp="abc"; then temp1 gets- "abcabcabc" why is that?

      R Offline
      R Offline
      Rajeshwar Code Developer
      wrote on last edited by
      #2

      Try !ispostback

      try and try untill reach success..

      M N 2 Replies Last reply
      0
      • R Rajeshwar Code Developer

        Try !ispostback

        try and try untill reach success..

        M Offline
        M Offline
        michaelgr1
        wrote on last edited by
        #3

        how do i use it?

        1 Reply Last reply
        0
        • M michaelgr1

          Hello, When i am trying to copy stringbuilder to string it copies the same string twice or 3 times for example if i do: stringbuilder temp=new stringbuilder(); string temp1; temp1=temp.tostring(); if temp="abc"; then temp1 gets- "abcabcabc" why is that?

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          I don't know about your code, but if I try it, it works well done : temp1 = abc temp = abc

          StringBuilder temp = new StringBuilder();
          temp.Append("abc");
          string temp1;
          temp1 = temp.ToString();
          Console.Write(temp1);

          1 Reply Last reply
          0
          • R Rajeshwar Code Developer

            Try !ispostback

            try and try untill reach success..

            N Offline
            N Offline
            Not Active
            wrote on last edited by
            #5

            IsPostback is relevant to ASP.NET. The OP did not say what environment he was using so your answer could be completely irrelevant and worse misleading.


            I know the language. I've read a book. - _Madmatt

            1 Reply Last reply
            0
            • M michaelgr1

              Hello, When i am trying to copy stringbuilder to string it copies the same string twice or 3 times for example if i do: stringbuilder temp=new stringbuilder(); string temp1; temp1=temp.tostring(); if temp="abc"; then temp1 gets- "abcabcabc" why is that?

              N Offline
              N Offline
              Not Active
              wrote on last edited by
              #6

              You haven't shown any code that actually adds values to the stringbuilder. Where is that? Are you calling it multiple times perhaps.


              I know the language. I've read a book. - _Madmatt

              M 1 Reply Last reply
              0
              • N Not Active

                You haven't shown any code that actually adds values to the stringbuilder. Where is that? Are you calling it multiple times perhaps.


                I know the language. I've read a book. - _Madmatt

                M Offline
                M Offline
                michaelgr1
                wrote on last edited by
                #7

                I fount my mistake. I had a method that returns a stringbuilder and receives a stringbuilder. for example: private stringbuilder method1(stringbuilder temp) { temp.append("abc"); } private void main_method() { stringbuilder main=new stringbuilder(); main.append(method1(main)); } something like that

                1 Reply Last reply
                0
                • M michaelgr1

                  Hello, When i am trying to copy stringbuilder to string it copies the same string twice or 3 times for example if i do: stringbuilder temp=new stringbuilder(); string temp1; temp1=temp.tostring(); if temp="abc"; then temp1 gets- "abcabcabc" why is that?

                  realJSOPR Offline
                  realJSOPR Offline
                  realJSOP
                  wrote on last edited by
                  #8

                  michaelgr1 wrote:

                  if temp="abc";

                  Hmmmm.... Show us as much of the actual associated code as you can...

                  .45 ACP - because shooting twice is just silly
                  -----
                  "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                  -----
                  "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

                  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