Just use the already built-in Contains() method:
using System.Linq;
//...
string[] array = { "foo", "bar" };
if (array.Contains("foo")) {
//...
}
More Related Contents:
- String Operation using Linq
- Converting strings to arrays c#
- C# String Array Returns Wrong Values
- How to convert UTF-8 byte[] to string
- How to access random item in list?
- Using C# to check if string contains a string in string array
- .NET / C# – Convert char[] to string
- Check if a value is in an array (C#)
- Checking if a string array contains a value, and if so, getting its position
- Convert array of integers to comma-separated string
- Pick Random String From Array
- string.Join on a List or other type
- Operator ‘==’ cannot be applied to operands of type ‘char’ and ‘string’
- convert string array to string
- How can I safely convert a byte array into a string and back? [duplicate]
- Is string actually an array of chars or does it just have an indexer?
- How to cut up a string from an input file with Regex or String Split, C#?
- Compression/Decompression string with C#
- How do I read a specified line in a text file?
- Get file name from URI string in C#
- Memory Efficiency and Performance of String.Replace .NET Framework
- Parse C# string to DateTime
- Return char[]/string from a function [duplicate]
- C# quickest way to shift array
- C# hex to ascii
- C# params object[] strange behavior
- Search for a string in Enum and return the Enum
- Get text between 2 html tags c#
- Adding a newline into a string in C#
- How can I create all possible combinations for a set of words without repetition?