Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
C# Linq Contains Method
To check for an element in a string, use the Contains() method.
The following is our string array.
string[] arr = { "Java", "C++", "Python"};
Now, use Contains() method to find a specific string in the string array.
arr.AsQueryable().Contains(str);
Let us see the complete example.
Example
using System;
using System.Linq;
using System.Collections.Generic;
class Demo {
static void Main() {
string[] arr = { "Java", "C++", "Python"};
string str = "Python";
bool res = arr.AsQueryable().Contains(str);
Console.WriteLine("Array has Python? "+res);
}
}
Output
Array has Python? True
Advertisements
