0

I want to do something like we can do in VB. I have a string value which is "Dreamboy". now i would like to extract some characters from a specified position within the above string. we can do this in vb by using mid,left and right functions. now i need to know how can it be achieved in C#.

Plz tell me...............

3
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by vbsqluser
0

You can use a member of System.String called Substring(). This member returns a string that represents a substring of the current string. For example, your sample text is"DreamBoy". Now suppose we only needed to retrieve "Boy" from "DreamBoy", your code would like something similar to this:

string s = "DreamBoy";
Console.WriteLine("Last part of string is: {0}", s.Substring(s.Length - 3));

I hope this somehow helps with what you are doing.

FraOgongi

0

Hi,

String oText, String oFind;


int iPos = oText.IndexOf(oFind);
String strReturn = "";
If (iPos != -1)
{
strReturn = oText.Substring(0, iPos);
}

Database programming using Visual Basic 2005

Edited by happygeek: fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.