
The example includes a call to the IndexOf(String) method if a substring is found in a string instance. If you are interested in the position of the substring value in the current instance, you can call the IndexOf method to get the starting position of its first occurrence, or you can call the LastIndexOf method to get the starting position of its last occurrence. ' Does 'This is a string.' contain 'this'? ' The example displays the following output: String^ s1 = "The quick brown fox jumps over the lazy dog" Ĭonsole::WriteLine( "Is the string, s2, in the string, s1?: ", comp, s.Contains(sub1, comp)) If "fox" is found in the string, it also displays its starting position. The following example determines whether the string "fox" is a substring of a familiar quotation. If you have user-generated content in your web application, chances are you have to deal with strings containing emojis.
