Linq one多个列表的结果

Byy*_*yyo 0 c# linq

我有一种计算得分的方法.简化:

public static int GetScore(int v1, int v2, char v3)
{
    //calculate score 
    return score;
}
Run Code Online (Sandbox Code Playgroud)

v1,v2并且v3是3个列表中的3个值:

List<int> Values1 = new List<int>();
List<int> Values2 = new List<int>();
List<char> Values3 = new List<char>();
//fill Values1, Values 2, Values3
Run Code Online (Sandbox Code Playgroud)

如何Select确定三个列表的每个组合并确定最高分?我想到了类似的东西:

int MaxScore = Values1.Select(x => Values2.Select(y => GetScore(x, y))).Max(); // ???
Run Code Online (Sandbox Code Playgroud)

我目前的做法

int MaxScore = 0;
foreach (int x in Values1)
{
    foreach (int y in Values2)
    {
        foreach (char z in Values3)
        {
            int Score = GetScore(x, y, z);
            if (Score > MaxScore)
            {
                MaxScore = Score;
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Maa*_*ten 6

在这种情况下,我认为LINQ Query语法更清晰.

var data = from v1 in Values1
           from v2 in Values2
           from v3 in Values3
           select GetScore(v1, v2, v3);
var max = data.Max();
Run Code Online (Sandbox Code Playgroud)