How can I use SUBSTRING and INSTRING in C# ?
Printable View
How can I use SUBSTRING and INSTRING in C# ?
Use the Substring and IndexOf methods of the String class.Note that .NET 2.0 strings have a Contains method as well.Code:string str = "Hello World";
MessageBox.Show(str.Substring(3, 4)); // Displays "lo W"
MessageBox.Show(str.IndexOf('W').ToString()); // Displays 6
Thanks for your answer.
Sohel