You could use the Array.IndexOf method:
string[] stringArray = { "text1", "text2", "text3", "text4" }; string value = "text3"; int pos = Array.IndexOf(stringArray, value); if (pos > -1) { // the array contains the string and the pos variable // will have its position in the array }
Related Posts:
- How to convert UTF-8 byte[] to string
- Convert an array to string
- How can I convert String to Int?
- Error : Index was outside the bounds of the array.
- Convert int to string?
- Converting string to byte array in C#
- All possible array initialization syntaxes
- Adding values to a C# array
- Adding values to a C# array
- How can I add ” character to a multi line string declaration in C#?
- C# equivalent of C++ map
- How to convert byte array to string [duplicate]
- How to convert byte array to string
- C# List
to string with delimiter - Convert a list of strings to a single string
- Adding values to a C# array
- C#: how to get first char of a string?
- Adding values to a C# array
- How to initialize a list of strings (List
) with many string values - What does {0} mean when found in a string in C#?
- C# – Illegal characters in path
- Getting The ASCII Value of a character in a C# string
- Reading CSV file and storing values into an array
- How can I fix the error : “Unreachable Code Detected”
- C# – How to convert string to char?
- Escape double quotes in a string
- Creating a comma separated list from IList
or IEnumerable - Remove element of a regular array
- Merging two arrays in .NET
- C# syntax to initialize custom class/objects through constructor params in array?
- Fastest way to remove first char in a String
- Substring index and length must refer to a location within the string
- How to add a string to a string[] array? There’s no .Add function
- Case insensitive ‘Contains(string)’
- Most efficient way to remove special characters from string
- Is there an equivalent to the Scanner class in C# for strings?
- Adding a newline into a string in C#
- How to format a string as a telephone number in C#
- .NET String.Format() to add commas in thousands place for a number
- How would you count occurrences of a string (actually a char) within a string?
- C# equivalent to Java’s charAt()?
- How do I concatenate two arrays in C#?
- What is a quick way to force CRLF in C# / .NET?
- Check if a string is a palindrome
- Best way to “push” into C# array
- Convert string to decimal, keeping fractions
- Convert JSON String to JSON Object c#
- Key Value Pair List
- Unrecognized escape sequence for path string containing backslashes
- Convert HTML to PDF in .NET
- How to show a loading gif while an APi is being called in xamarin android?
- ImageMagick creating blank transparent square(s) according to width
- .Net 4.8 Support for Windows 10 ends in 26 days?
- How do I generate a random int number?
- Why has the int32 type a maximum value of 2³¹ − 1? [duplicate]
- What is a NullReferenceException, and how do I fix it?
- How do I get a random YouTube video with the YouTube API?
- An existing connection was forcibly closed by the remote host
- C# HttpClient An existing connection was forcibly closed by the remote host
- What is a NullReferenceException, and how do I fix it?
- What is a PDB file?
- What is the { get; set; } syntax in C#?
- Unexplained crashes related to ntdll.dll
- Array to String PHP?
- I am getting Failed to load resource: net::ERR_BLOCKED_BY_CLIENT with Google chrome
- How can I parse JSON with C#?
- Can anyone explain IEnumerable and IEnumerator to me? [closed]
- What is parsing?
- What is IP address ‘::1’?
- CS0120: An object reference is required for the nonstatic field, method, or property ‘foo’
- IOException: The process cannot access the file ‘file path’ because it is being used by another process
- How to find child of a GameObject or the script attached to child GameObject via script
- Process cannot access the file because it is being used by another proess
- Getting mouse position in unity
- How to fix “HTTP Error 400. The size of the request headers is too long” error from azure cloud services?
- How do I create an array of strings in C?
- C# error: “An object reference is required for the non-static field, method, or property”
- Split string into array
- No connection could be made because the target machine actively refused it?
- How to convert a char array to a string?
- How to convert JSON to XML or XML to JSON?
- Virustotal Trapmine suspicious.low.ml.score
- Converting String to “Character” array in Java
- What is the difference between declarative and imperative paradigm in programming?
- How to fix No connection could be made because the target machine actively refused it 127.0.0.1:64527
- Could not load file or assembly or one of its dependencies
- What does a lock statement do under the hood?
- How to make the script wait/sleep in a simple way in unity
- What is the yield keyword used for in C#?
- Error : Could not load file or assembly or one of it’s dependencies
- Group by in LINQ
- Join/Where with LINQ and Lambda
- string to string array conversion in java
- Could not load file or assembly or one of its dependencies
- C# compiler error: “not all code paths return a value”
- Multiline string literal in C#
- What is C# equivalent of
- How to use SQLite in Visual Studio 2017?
- Algorithms in O(n^2) vs O(n) [duplicate]
- Unity OnTriggerEnter2D not registering