StringBuilder substring

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

    #1

    StringBuilder substring

    Substring returns a given string from a string. Is there an equivalent way to
    get a substring from a StringBuilder?
  • Yunus Emre ALPÖZEN [MCAD.NET]

    #2
    Re: StringBuilder substring

    System.Text.Str ingBuilder ToString Method has two overloads one has no
    parameter and the other one is the one that u are looking for.....

    public System.String ToString ( System.Int32 startIndex , System.Int32
    length )

    --

    Thanks,
    Yunus Emre ALPÖZEN
    BSc, MCAD.NET

    "Dave" <Dave@discussio ns.microsoft.co m> wrote in message
    news:ACE39913-0734-4068-96F5-A6204FFD03E4@mi crosoft.com...[color=blue]
    > Substring returns a given string from a string. Is there an equivalent way
    > to
    > get a substring from a StringBuilder?[/color]


    Comment

    • Dave

      #3
      Re: StringBuilder substring

      That's not quite what I needed. I need to do the following,

      StringBuilder sb1= new StringBuilder(" 0123456789")
      StringBuilder sb2= new StringBuilder(" old info")

      sb2= sb1(0,4) //wrong

      Giving sb2 equal to "0123"

      Of course the line above marked wrong is wrong. So how would I do this? I
      need the wrong line to clear out the old info and put in the first four
      character from the other stringbuilder object.

      "Yunus Emre ALPÖZEN [MCAD.NET]" wrote:
      [color=blue]
      > System.Text.Str ingBuilder ToString Method has two overloads one has no
      > parameter and the other one is the one that u are looking for.....
      >
      > public System.String ToString ( System.Int32 startIndex , System.Int32
      > length )
      >
      > --
      >
      > Thanks,
      > Yunus Emre ALPÖZEN
      > BSc, MCAD.NET
      >
      > "Dave" <Dave@discussio ns.microsoft.co m> wrote in message
      > news:ACE39913-0734-4068-96F5-A6204FFD03E4@mi crosoft.com...[color=green]
      > > Substring returns a given string from a string. Is there an equivalent way
      > > to
      > > get a substring from a StringBuilder?[/color]
      >
      >
      >[/color]

      Comment

      • James Curran

        #4
        Re: StringBuilder substring

        > StringBuilder sb1= new StringBuilder(" 0123456789")[color=blue]
        > StringBuilder sb2= new StringBuilder(" old info")[/color]

        sb2= new StringBuilder(s b1.ToString(0,4 ));


        --
        Truth,
        James Curran
        [erstwhile VC++ MVP]

        Home: www.noveltheory.com Work: www.njtheater.com
        Blog: www.honestillusion.com Day Job: www.partsearch.com

        "Dave" <Dave@discussio ns.microsoft.co m> wrote in message
        news:893DE8FE-1A66-4A39-8A5A-EE5ADA56C4AC@mi crosoft.com...[color=blue]
        > That's not quite what I needed. I need to do the following,
        >
        > StringBuilder sb1= new StringBuilder(" 0123456789")
        > StringBuilder sb2= new StringBuilder(" old info")
        >
        > sb2= sb1(0,4) //wrong
        >
        > Giving sb2 equal to "0123"
        >
        > Of course the line above marked wrong is wrong. So how would I do this? I
        > need the wrong line to clear out the old info and put in the first four
        > character from the other stringbuilder object.[/color]


        Comment

        Working...