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. covert string to particular pattern

covert string to particular pattern

Scheduled Pinned Locked Moved C#
tutorialregexquestion
2 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.
  • A Offline
    A Offline
    Amjath Rahman
    wrote on last edited by
    #1

    Hi All, For example im having a string like this "0:30:1A:1E:55:2" i want to convert this string to "00:30:1A:1E:55:02" how can i do this. right now im split the string using ':' and then find the length if its 1 then add 0 in front of it, it works fine for me.... but i think some simpler way must be there.... so plz guide me if am wrong With Regards Amjath

    M 1 Reply Last reply
    0
    • A Amjath Rahman

      Hi All, For example im having a string like this "0:30:1A:1E:55:2" i want to convert this string to "00:30:1A:1E:55:02" how can i do this. right now im split the string using ':' and then find the length if its 1 then add 0 in front of it, it works fine for me.... but i think some simpler way must be there.... so plz guide me if am wrong With Regards Amjath

      M Offline
      M Offline
      Michael Sync
      wrote on last edited by
      #2

      Amjath Rahman wrote:

      add 0 in front of it

      String.PadLeft Method[^] Dim str As String Dim pad As Char str = "forty-two" pad = "."c Console.WriteLine(str.PadLeft(15, pad)) ' Displays "......forty-two". Console.WriteLine(str.PadLeft(2, pad)) ' Displays "forty-two".

      Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

      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