Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 21st, 2008, 12:44 PM
Registered User
Join Date: Dec 2007
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default substring in c#


I want to find out the substring value from the string:
and output should be:

 what I am trying to do is bellow

string st = "savi-server\test";

But It return only the


Please help me, I need the output as: test

Thanks in advance

Reply With Quote
  #2 (permalink)  
Old February 21st, 2008, 01:29 PM
Friend of Wrox
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts


Right, in your example, I believe you want st.Substring(11,4); But for a more useful approach, try this:

string st = "savi-server\test";
return st.Substring(st.IndexOf("\") + 1);

Try that first; essentially, it will start from the first t, and take the rest of the line. You may not need the +1, so if that doesn't work, try removing the +1.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Substring-before with Regex bonekrusher XSLT 6 November 27th, 2007 01:16 PM
substring-before() function. lafilip XSLT 1 July 11th, 2007 05:33 PM
Substring-after collation bonekrusher XSLT 2 May 11th, 2007 09:31 AM
SubString prasanta2expert Access VBA 1 November 17th, 2006 10:04 AM
How to find substring chrscote Classic ASP Basics 1 June 14th, 2003 03:13 AM

All times are GMT -4. The time now is 08:20 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.