Alternatively, you can use the Contains() method with the StringComparison parameter to check if a string contains a substring in a case-insensitive manner.
he Contains() method is used with the StringComparison.OrdinalIgnoreCase parameter to check if the string "Hello, World!" contains the substring "WORLD" in a case-insensitive manner. The resulting boolean variable contains is true because the substring is found (even though the case is different).
use the IndexOf() method with the StringComparison parameter to perform a case-insensitive search for a substring within a string.
the IndexOf() method is used with the StringComparison.OrdinalIgnoreCase parameter to perform a case-insensitive search for the substring "WORLD" within the string "Hello, World!". The resulting boolean variable contains is true because the substring is found (even though the case is different).
Note that the IndexOf() method returns the zero-based index of the first occurrence of the specified substring within the string, or -1 if the substring is not found. In this case, we're checking whether the result of IndexOf() is greater than or equal to 0, which indicates that the substring is found.