Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 21st, 2008, 12:44 PM
Registered User
Join Date: Dec 2007
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

Old February 21st, 2008, 01:29 PM
Friend of Wrox
Join Date: Jun 2003
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.


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

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