How to find Index of a string or a character in C# ?
Use IndexOf method.
Use GetIndex Method.
Use Index property.
Use Index method.
Using IndexOf method we can find the position of a character or a string in a given string .
Sample Code for identifying char 'i' in a string s having "skill" .
string s= "skill";
int position= s.IndexOf('i') ;
The above IndexOf method will give position of first matched character that is 3 ( since index starts from zero )
For getting position of last matched character use LastIndexOf method .
Back To Top