First this is wrong: string array[,] = new string[1,6]{{"texto","","","","",""}};
Should be: string[,] array = new string[1, 6] { { "texto", "", "", "", "", "" } };
Here the function you seek:
public static int IndexOfStringInArrayOfStrings(string[,] arrayDeStrings, string stringQueVocêProcura, int colunaEmQueAFunçãoDeveProcurar)
{
for (int i = 0; i < arrayDeStrings.Length; i++) // Aqui eu percorro todas as linhas.
{
if (arrayDeStrings[i, colunaEmQueAFunçãoDeveProcurar].Contains(stringQueVocêProcura)) // Aqui eu checo se na célula[i, j] têm a string que você procura.
{
return i; // Caso tenha a string, imediatamente a função se encerra e retorna sua posição. 0 = Primeira linha do texto.
}
}
return -1; // Se chegar até o fim, certamente não encontrou nada.
}
I am closing because by the answer posted only the author could answer the question. There were requirements not clearly set out in the question.
– Maniero
I’m feeling here on this forum that I’ve reached a few days, a slightly competitive air, man I don’t want reputation points or anything like that, if you can even delete the question, I just had a question, and I managed to solve my problem with a go, And it was only after seeing the example of your answer that I came up with the idea of using a for in a simpler way. Thank you all for your help.
– Moribundo Chat
The question is not this, is that the question is not clear, only you could have answered the way you wanted, the answer portando is not clear, and answers that are not clear need to be closed, even because the person who will read it later and try to learn from it will get confused because what is written is different than what had to be answered. If you want to talk more property about the operation of the site you can do the [tour] and see the details on [help]. Reinforce the warning above about [Ask]. Thus avoids confusion and difficulties p/q people give adequate answers
– Maniero
The Expensive managed to give an adequate response, and yours can also be said to be adequate, for what may be suitable for my situation is different to what might be suitable for the situation of another.
– Moribundo Chat
As for competitiveness you are right that some people take it there extreme. I received a negative in the reply without knowing why. It is complete and as correct as possible. I even updated it to agree with your response. I did not deny yours, because it is not wrong, at most it does not work in all situations, but this is something you should decide whether you want it like this or not, my answer serves other people who want the most correct. I only denied the wrong answer, after all it does not do what desired, gives error,and showed in comment because mine works correctly
– Maniero
The answer of the expensive is quite wrong, for any case, his answer gives easy error, has performance problems, does not answer what you really wanted, among other small things that are more subjective. Yours is correct, as long as you make sure array was created within the norm, if it was created with track out of normal its gives error too, but okay, as this is rare I will not consider that yours is wrong. Mine does everything that is in the question and even more. If it was not exactly what you wanted it is because the question is not clear on that. Requirements are missing.
– Maniero
So that’s what I’m saying, in my situation the best would be what I did, but maybe for someone else it’s what you did. As for -1 it wasn’t me, I didn’t even know it existed until I read your comment ali kkkkk
– Moribundo Chat
Don’t worry that I know it wasn’t you, you don’t even have the privilege of negative yet. Just to confirm what I said about the reply from dear: https://dotnetfiddle.net/ueBlhi
– Maniero