I am trying to write a method which should return the item value based on value index and condition.
For example, in the below, if I pass index value as 0, it should return keys and first value from integer array which is not having value 5.
public static Dictionary<string, int[]> _dict = new Dictionary<string, int[]>()
{
{"A", [1,0,3] },
{"B", [5,1,5] },
{"C", [7,11,5] },
{"D", [0,1,5]},
{"E", [14,0,5] },
{"F", [5,1,5] }
};
Expected O/P:
if I pass index value 0, and condition as != 5 then O/P should be
{
{"A", 1 },
{"C", 7 },
{"D", 0 },
{"E", 14}
};
2
Answers
You could achieve this in two steps:
5
or using LINQ
Complete code would look something like
GetResult(valueIndex: 0, predicate: a => a.Value[0] != 5)
then gives the result you wantOne line code using
LINQ