- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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