.Net Code Monkey RSS 2.0
 Saturday, November 15, 2008

Another discovery today, courtesy of Google finding Rik Robinson's Blog is String.TrimStart() and String.TrimEnd().

To trim a leading slash of a string or path use:

myString = myString.TrimStart(new char[]{'\\', '/'}); 

 

To trim a trailing slash of a string or path use:

myString = myString.TrimEnd(new char[]{'\\', '/'}); 

 

I had previously been using a much more long-winded approach. Cheers Rik for bringing that to my attention.

Saturday, November 15, 2008 11:17:15 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
.Net | C#
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview
Archive
<January 2009>
SunMonTueWedThuFriSat
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567
Blogroll
 Clemens Vasters
 Harry Pierson
Passion * Technology * Ruthless Competence
 Joshua Flanagan
A .NET Software Developer
 Michael Schwarz's Blog
Developing applications on the Microsoft platform since Windows 3.1!
 Omar Shahine
Yet another Microsoft blogger
 Scot GU
Scott Guthrie lives in Seattle and builds a few products for Microsoft
 Scott Hanselman
Programming Life and the Zen of Computers
 Tom Mertens
Tom's corner
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2009
Duane Wingett
Sign In
Statistics
Total Posts: 21
This Year: 0
This Month: 0
This Week: 0
Comments: 8
Themes
Pick a theme:
All Content © 2009, Duane Wingett
DasBlog theme 'Business' created by Christoph De Baene (delarou)