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. string resizing

string resizing

Scheduled Pinned Locked Moved C#
algorithmstutorialquestion
6 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.
  • E Offline
    E Offline
    Emmet_Brown
    wrote on last edited by
    #1

    Hi all, I want to resize my string, getting rid of the last 5 chars. for example: after I do this:

    string a= "example string 4444";
    SomeMethod(a);

    I want 'a' to become "example string" and " 4444" chars will be lost. Is there a built-in function for such thing or should I create a simple algorithm? Thanks...

    L R C 3 Replies Last reply
    0
    • E Emmet_Brown

      Hi all, I want to resize my string, getting rid of the last 5 chars. for example: after I do this:

      string a= "example string 4444";
      SomeMethod(a);

      I want 'a' to become "example string" and " 4444" chars will be lost. Is there a built-in function for such thing or should I create a simple algorithm? Thanks...

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

      Something like SubString?

      E 1 Reply Last reply
      0
      • L Lost User

        Something like SubString?

        E Offline
        E Offline
        Emmet_Brown
        wrote on last edited by
        #3

        I knew there was sth like this, I remember it from C times. All I've got to do is to assign the "string size - 5" for starting pos. thanks for reminding :D

        L 1 Reply Last reply
        0
        • E Emmet_Brown

          I knew there was sth like this, I remember it from C times. All I've got to do is to assign the "string size - 5" for starting pos. thanks for reminding :D

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Emmet_Brown wrote:

          assign the "string size - 5" for starting pos length

          FTFY

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


          Happy New Year to all.
          We hope 2010 soon brings us automatic PRE tags!
          Until then, please insert them manually.


          1 Reply Last reply
          0
          • E Emmet_Brown

            Hi all, I want to resize my string, getting rid of the last 5 chars. for example: after I do this:

            string a= "example string 4444";
            SomeMethod(a);

            I want 'a' to become "example string" and " 4444" chars will be lost. Is there a built-in function for such thing or should I create a simple algorithm? Thanks...

            R Offline
            R Offline
            Rick Shaub
            wrote on last edited by
            #5

            string a= "example string 4444";
            int numToRemove = 5;

            a = a.Remove(a.Length - numToRemove - 1, numToRemove);

            1 Reply Last reply
            0
            • E Emmet_Brown

              Hi all, I want to resize my string, getting rid of the last 5 chars. for example: after I do this:

              string a= "example string 4444";
              SomeMethod(a);

              I want 'a' to become "example string" and " 4444" chars will be lost. Is there a built-in function for such thing or should I create a simple algorithm? Thanks...

              C Offline
              C Offline
              carlecomm
              wrote on last edited by
              #6

              Hi, use the substring function. eg. a.SubString(0,14);

              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