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