c# - Finding an index of an element in a string array -


I did a search on this forum to find the indicator of an element in a string array. The solution I've found uses the following method:

Array.IndexOf

I am new to C # and I have not yet heard about this method. I can find an indicator for integer, however I am struggling to find a solution for string type array.

Here is the code that I search for indicator for integers:

  Public int search (int test value) {int i = 0; While (i & lt; test.Length & testValue! = Test [i]) i ++; If (i == test.Length) i = -1; Return i; }   

How do I modify above, to be able to use for string type array, or any other simple method that will do the trick?

I think, you need the following example. If you need another example or need another solution, let me know.

  string [vals = {"val1", "val2", "val3"}; Int idx = array.indexoff (wall, "vel 2");    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -