Learn how to use the C# String Contains method to determine if a specified substring exists within a string. Explore examples and syntax to enhance your programming skills.
public bool Contains (char value); Parameters value Char The character to seek. Returns Boolean true if the value parameter occurs within this string; otherwise, false. Remarks This method performs an ordinal (case-sensitive and culture-insensitive) comparison. Applies to .NET 9 और अ...
The String.Contains() method in C# is used to return a value indicating whether a specified substring occurs within this string. Syntax public bool Contains (string val); Above, val is the string to search for. Advertisement - This is a modal window. No compatible source was found for ...
Returns true if and only if this string contains the specified sequence of char values. Contains(ICharSequence) Returns true if and only if this string contains the specified sequence of char values. C# [Android.Runtime.Register("contains","(Ljava/lang/CharSequence;)Z","")]publicboolContains...
Returns true if and only if this string contains the specified sequence of char values. Contains(String) Returns true if and only if this string contains the specified sequence of char values. Contains(ICharSequence) Returns true if and only if this string contains the spec...
Tests whether the specified string contains the specified substring and throws an exception if the substring does not occur within the test string.
以下示例程序旨在说明Contains()方法。 程序1: // C# program to demonstrate the// String.Contains() Methodusing System;classGeeks{// Main MethodpublicstaticvoidMain() {// string typeStringstr ="GeeksforGeeks";Stringsubstr1 ="for";Stringsubstr2 ="For";// using String.Contains() MethodConsole....
publicboolContains(stringvalue, StringComparison comparisonType); 参数 value String 要搜寻的字符串。 comparisonType StringComparison 一个枚举值,用于指定比较中要使用的规则。 返回 Boolean 如果true参数出现在此字符串中,或者value为空字符串 (""),则为value;否则为false。
Tests whether the specified string contains the specified substring and throws an exception if the substring does not occur within the test string.
StringmyStr="Hello";System.out.println(myStr.contains("Hel"));// trueSystem.out.println(myStr.contains("e"));// trueSystem.out.println(myStr.contains("Hi"));// false Try it Yourself » Definition and Usage Thecontains()method checks whether a string contains a sequence of characters...