C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C# String Contains()The C# Contains() method is used to return a value indicating whether the specified substring occurs within this string or not. If the specified substring is found in this string, it returns true otherwise false. Signaturepublic bool Contains(String str) Parametersstr: it is a string object which is used to check occurrence in the calling string. ReturnIt returns boolean value either true or false. C# String Contains() method Exampleusing System; public class StringExample { public static void Main(string[] args) { string s1 = "Hello "; string s2 = "He"; string s3 = "Hi"; Console.WriteLine(s1.Contains(s2)); Console.WriteLine(s1.Contains(s3)); } } Output: True False
Next TopicC# String Copy()
|