Here, we use IndexOf to see if a string contains a word. We must test for -1 if no value may exist.Īnd: Because -1 is returned in normal situations, we usually need if-statements with IndexOf. Return: It returns negative one when nothing is found. This method, a string method, returns the first index of a letter in a string. We simplify these operations with IndexOf. These characters may be searched and tested. IndexOf returns the first index of specified character or substring. This C# tutorial shows the IndexOf method.
0 Comments
Leave a Reply. |