I can not remember how to use the C# equivalent of "FIND" to locate a character's position in a string. Once I find the position I am searching for a Substring method to extract up to that. Can anyone point me to some documentation?

Recommended Answers

All 3 Replies

use string.IndexOf()

As Scott said, use YourStringVariable.IndexOf("Value to Search")
and then use the SubString method to extract what you want.

char ch;
string str1,str2;
int num;
num = str1.IndexOf(ch);
str2 = cadena.Substring(num);
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.