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. trim away the first letter in string?

trim away the first letter in string?

Scheduled Pinned Locked Moved C#
tutorialquestion
6 Posts 4 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.
  • S Offline
    S Offline
    Support123
    wrote on last edited by
    #1

    Hi all, How would i go about trimming the first character in a string? Example: I want to add "+27" to the Variable that contains "0721234567". But first i need to delete the "0" from the Variable. So then the Variable will contain "+27721234567". Thank you in advance. :)

    "Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison

    T F C 3 Replies Last reply
    0
    • S Support123

      Hi all, How would i go about trimming the first character in a string? Example: I want to add "+27" to the Variable that contains "0721234567". But first i need to delete the "0" from the Variable. So then the Variable will contain "+27721234567". Thank you in advance. :)

      "Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison

      T Offline
      T Offline
      Tamimi Code
      wrote on last edited by
      #2

      hi dim str as string = "0721234567" dim strNew as string = str.Substring(1) str = "+27" & strNew

      Tamimi - Code

      S 1 Reply Last reply
      0
      • S Support123

        Hi all, How would i go about trimming the first character in a string? Example: I want to add "+27" to the Variable that contains "0721234567". But first i need to delete the "0" from the Variable. So then the Variable will contain "+27721234567". Thank you in advance. :)

        "Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison

        F Offline
        F Offline
        freshonlineMax
        wrote on last edited by
        #3

        Ok string strNumber="0721234567"; string strPreCode="+27"; strNumber = strPreCode + strNumber.Substring(1,strNumber.Length-1); this code add PreCode(+27) to first of Number(0721234567), but first remove zero(0) from first position of Number.

        S 1 Reply Last reply
        0
        • T Tamimi Code

          hi dim str as string = "0721234567" dim strNew as string = str.Substring(1) str = "+27" & strNew

          Tamimi - Code

          S Offline
          S Offline
          Support123
          wrote on last edited by
          #4

          Thank you for your time.

          "Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison

          1 Reply Last reply
          0
          • F freshonlineMax

            Ok string strNumber="0721234567"; string strPreCode="+27"; strNumber = strPreCode + strNumber.Substring(1,strNumber.Length-1); this code add PreCode(+27) to first of Number(0721234567), but first remove zero(0) from first position of Number.

            S Offline
            S Offline
            Support123
            wrote on last edited by
            #5

            Thank you for your time.

            "Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison

            1 Reply Last reply
            0
            • S Support123

              Hi all, How would i go about trimming the first character in a string? Example: I want to add "+27" to the Variable that contains "0721234567". But first i need to delete the "0" from the Variable. So then the Variable will contain "+27721234567". Thank you in advance. :)

              "Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison

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

              hi , string s = "0721234567"; if(s.StartsWith("0")) s= s.Replace("0","+27"); cheers.

              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