I have been looking for a long time now, to find any smarter solution than mine, to gather index and value of an item in my array. I can not search directly on the item because there will always be some other char in the string. Here is an example of what I want to do.
// logcontent = ["f", "red", "frs", "xyr", "frefff", "xdd", "to"]
string lineData = "";
int lineIndex = 0;
foreach (var item in logContent.Select((value, index) => new { index, value }))
{
string line = item.value;
var index = item.index;
if (line.Contains("x"))
{
lineData = line;
lineIndex = index;
break;
}
}
I want to only get the next item
lineData = "xyr";
lineIndex = 3;