I have an 2D array like this:
string[,] ClassNames =
{
{"A","Red"},
{"B","Blue"},
{"C","Pink"},
{"D","Green"},
{"X","Black"},
};
i search ClassName in 1nd column by for statement and return ColorName in 2nd column like this:
string className = "A";
string color = "Black";
for (int i = 0; i <= ClassNames.GetUpperBound(0); i++)
{
if (ClassNames[i, 0] == className)
{
color = ClassNames[i, 1];
Response.Write(color);
break;
}
}
i want use LINQ instead of for statement to get the color by className. how to convert above for statement to LINQ.