I have the following code. I would like to replace the for
loop to a lambda or LINQ expression to return my string.
string[,] testval = new string[3,2]
testval[0, 0] = "0"
testval[0, 1] = "string A"
testval[1, 0] = "5"
testval[1, 1] = "string B"
testval[2, 0] = "13"
testval[2, 1] = "string C"
string teststring = "13"
for (int i=0; i<=testval.GetUpperBound(0);i++)
{
if (testval[i,0] == teststring) { return testval[i,1]; }
}
return null;
I am new to lambda and LINQ expressions. Can somebody help me?