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. C# Right and Left Methods

C# Right and Left Methods

Scheduled Pinned Locked Moved C#
csharphelpquestion
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.
  • B Offline
    B Offline
    Brendan Vogt
    wrote on last edited by
    #1

    Hi, Does C# have similar methods to VB's Right and Left methods/functions? Lets say I have the following: string myName = "codeproject"; I need the first (left) 2 and last (right) 2 characters of this string. What I tried was the following, but somehow it feels that there are maybe better ways of doing it: int start = myName.Length-2; Response.Write(myName.Substring(5, 2)); Please can someone help. Regards, Brendan

    J 1 Reply Last reply
    0
    • B Brendan Vogt

      Hi, Does C# have similar methods to VB's Right and Left methods/functions? Lets say I have the following: string myName = "codeproject"; I need the first (left) 2 and last (right) 2 characters of this string. What I tried was the following, but somehow it feels that there are maybe better ways of doing it: int start = myName.Length-2; Response.Write(myName.Substring(5, 2)); Please can someone help. Regards, Brendan

      J Offline
      J Offline
      jonny5
      wrote on last edited by
      #2

      Substring is all you have, I believe.

      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