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. How could this not work?

How could this not work?

Scheduled Pinned Locked Moved C#
question
4 Posts 3 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.
  • N Offline
    N Offline
    nicknotyet
    wrote on last edited by
    #1

    string str = (string)value; int i = str.IndexOf("."); str.Remove(i, 1);

    N 1 Reply Last reply
    0
    • N nicknotyet

      string str = (string)value; int i = str.IndexOf("."); str.Remove(i, 1);

      N Offline
      N Offline
      nicknotyet
      wrote on last edited by
      #2

      Because its not assigned to anything I'm still thinking like a 'C' prgrammer. Doh!

      L G 2 Replies Last reply
      0
      • N nicknotyet

        Because its not assigned to anything I'm still thinking like a 'C' prgrammer. Doh!

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

        Remember strings in C# are immutable, so you need something like str = str.Remove(i, 1) if you want to modify a string. regards

        1 Reply Last reply
        0
        • N nicknotyet

          Because its not assigned to anything I'm still thinking like a 'C' prgrammer. Doh!

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          It works just fine, it even creates the string that you want. It's only that you don't keep the reference to the string, so it floats around in heap limbo until it gets garbage collected. :) So close... ;)

          --- b { font-weight: normal; }

          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