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
- What is IP address ‘::1’?
- What is the yield keyword used for in C#?
- Join/Where with LINQ and Lambda
- C# compiler error: “not all code paths return a value”
- The page was not displayed because the request entity is too large on IIS
- Export Pervasive to MySQL (C#)
- Why use the params keyword?
- What does plus equals(+=) operator means here?
- The request was aborted: Could not create SSL/TLS secure channel
- finding the maximum length of lists in c#
- The located assembly’s manifest definition does not match the assembly reference
- OnTriggerEnter not working at Unity3D
- The requested resource does not support HTTP method ‘GET’
- What does mscorlib stand for?
- What is the best way to iterate over a dictionary?
- Convert array of strings into a string in Java
- What is and how to fix System.TypeInitializationException error?
- How to print elements from array with javascript
- How to use html.ValidationMessageFor
- EF 5 Enable-Migrations : No context type was found in the assembly
- Visual studio 2019 freezes when debugging
- How to make an HTTP POST web request
- How to stop C# console applications from closing automatically? [duplicate]
- Can I send SMS Messages from a C# Application?
- How do you sort a dictionary by value?
- EntityType has no key defined error
- regular expression “.*[^a-zA-Z0-9_].*”
- Sharing violation IOException while reading and writing to file C#
- How to delete object?
- Carriage return and Line feed… Are both required in C#?
- Cannot implicitly convert type ‘int’ to ‘string’ C# class
- If a folder does not exist, create it
- C# “No suitable method found to override.” — but there is one
- How to convert datetime format to date format in crystal report using C#?
- When do we use ANTLR
- Rotate object in Unity 3D
- How to play a sound in C#, .NET
- Convert SQL to LINQ Query
- How to resolve file being used by another process?
- How to crop an image using C#?
- How do you wait for input on the same Console.WriteLine() line?
- Why doesn’t C# have header files? Will the namespace take care of everything?
- How to avoid a System.Runtime.InteropServices.COMException?
- Define: What is a HashSet?
- Format of the initialization string does not conform to specification starting at index 0
- How can I generate random alphanumeric strings?
- How do you do a deep copy of an object in .NET?
- C# function to return array
- Cannot declare instance members in a static class in C#
- Remove empty array elements
- How to convert HTML to PDF using iTextSharp