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...............

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.