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. Delete a string from a string array.

Delete a string from a string array.

Scheduled Pinned Locked Moved C#
data-structurestutorial
9 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.
  • P Offline
    P Offline
    Praveen029
    wrote on last edited by
    #1

    how to delete a string from a string array.

    G V M M 4 Replies Last reply
    0
    • P Praveen029

      how to delete a string from a string array.

      G Offline
      G Offline
      Giorgi Dalakishvili
      wrote on last edited by
      #2

      Have a look at String.Replace method but remember that it will delete all occurrences from the string

      #region signature my articles #endregion

      1 Reply Last reply
      0
      • P Praveen029

        how to delete a string from a string array.

        V Offline
        V Offline
        V 0
        wrote on last edited by
        #3

        you want to diminsish the size of the array or put a null or "" instead?

        1 Reply Last reply
        0
        • P Praveen029

          how to delete a string from a string array.

          M Offline
          M Offline
          Martin 0
          wrote on last edited by
          #4

          Hello, I would suggest to use the System.Collections.Specialized.StringCollection class instead. All the best, Martin

          G P 2 Replies Last reply
          0
          • M Martin 0

            Hello, I would suggest to use the System.Collections.Specialized.StringCollection class instead. All the best, Martin

            G Offline
            G Offline
            Giorgi Dalakishvili
            wrote on last edited by
            #5

            You can also use StringBuilder. It depends how many times you will use it

            #region signature my articles #endregion

            M 1 Reply Last reply
            0
            • G Giorgi Dalakishvili

              You can also use StringBuilder. It depends how many times you will use it

              #region signature my articles #endregion

              M Offline
              M Offline
              Martin 0
              wrote on last edited by
              #6

              Hello, I wouldn't prevere the StringBuilder as an alternative to a string[]. I would miss methods like Contains. Allt he best, Martin

              1 Reply Last reply
              0
              • M Martin 0

                Hello, I would suggest to use the System.Collections.Specialized.StringCollection class instead. All the best, Martin

                P Offline
                P Offline
                Praveen029
                wrote on last edited by
                #7

                hello, Thanks my problem solved

                M 1 Reply Last reply
                0
                • P Praveen029

                  how to delete a string from a string array.

                  M Offline
                  M Offline
                  mav northwind
                  wrote on last edited by
                  #8

                  You can't easily. You'd have to copy the array to a second array leaving out the string you don't want. Just use List<string> instead.

                  Regards, mav -- Black holes are the places where God divided by 0...

                  1 Reply Last reply
                  0
                  • P Praveen029

                    hello, Thanks my problem solved

                    M Offline
                    M Offline
                    Martin 0
                    wrote on last edited by
                    #9

                    You are wellcome!

                    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