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. character replace

character replace

Scheduled Pinned Locked Moved C#
question
4 Posts 2 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
    pavya_Cool
    wrote on last edited by
    #1

    Hi to all, I have one string "Ganges: River Of Life" & i want to replace ':' character with space. i have following code but it is not working. str = "Ganges: River Of Life"; str.Replace(':',' '); Anybody tell me why this happened?

    Pravin

    G 1 Reply Last reply
    0
    • P pavya_Cool

      Hi to all, I have one string "Ganges: River Of Life" & i want to replace ':' character with space. i have following code but it is not working. str = "Ganges: River Of Life"; str.Replace(':',' '); Anybody tell me why this happened?

      Pravin

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

      The reason is that Replace function doesn't modify its parameter, it just returns new string so your code should look like this:

      str=str.Replace(':',' ');

      #region signature my articles #endregion

      P 1 Reply Last reply
      0
      • G Giorgi Dalakishvili

        The reason is that Replace function doesn't modify its parameter, it just returns new string so your code should look like this:

        str=str.Replace(':',' ');

        #region signature my articles #endregion

        P Offline
        P Offline
        pavya_Cool
        wrote on last edited by
        #3

        thanks Giorgi Dalakishvili, code is working now...! thanks again.

        Pravin

        G 1 Reply Last reply
        0
        • P pavya_Cool

          thanks Giorgi Dalakishvili, code is working now...! thanks again.

          Pravin

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

          Glad to help you :)

          #region signature my articles #endregion

          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