C# 代码的lambda表达式等价于什么

C# 代码的lambda表达式等价于什么,c#,lambda,C#,Lambda,我有这段代码,不知道它的lambda表达式是什么。我试过了,事实上,我读过了同样的高级教程,仍然无法从注释行开始理解以下代码的lambda表达式 IDictionary<string, GitItem> mappedPathToGitItems = new Dictionary<string, GitItem>(); mappedPathToGitItems = clientWrapper.GetFilePathToGitItems( gitLatest

我有这段代码,不知道它的lambda表达式是什么。我试过了,事实上,我读过了同样的高级教程,仍然无法从注释行开始理解以下代码的lambda表达式

IDictionary<string, GitItem> mappedPathToGitItems = new Dictionary<string, GitItem>();

mappedPathToGitItems = clientWrapper.GetFilePathToGitItems(
        gitLatestCommit, versionDescriptor, mappedPath, maxBatchSize);

List<string> filepaths = new List<string>();

// Lambda expression starts from here
// filepaths = {Lambda expression of the below code.}
foreach(KeyValuePair<string, GitItem> entry in mappedPathToGitItems)
{
    string item = entry.Key;
    GitItem gitItem = entry.Value;

    if(gitItem != null)
    {
        filepaths.Add(item);
    }
}
// Ends here
IDictionary MappedPathTogiItems=new Dictionary();
MappedPathTogiItems=clientWrapper.GetFilePathTogiItems(
gitLatestCommit、versionDescriptor、mappedPath、maxBatchSize);
列表文件路径=新列表();
//Lambda表达式从这里开始
//filepath={下面代码的Lambda表达式。}
foreach(MappedPathTogiItems中的KeyValuePair条目)
{
字符串项=entry.Key;
GitItem=entry.Value;
if(gitItem!=null)
{
添加(项);
}
}
//到此为止
列出文件路径=MappedPathTogiItems
.Where(kvp=>kvp.Value!=null)
.Select(kvp=>kvp.Key)
.ToList();
当您说“lambda表达式等效”时,我假设您的意思是通过LINQ:

List<string> filepaths = mappedPathToGitItems.Where(item => item.Value != null)
                                             .Select(item => item.Key)
                                             .ToList();
List filepath=mappedPathToGitItems.Where(item=>item.Value!=null)
.Select(item=>item.Key)
.ToList();
List<string> filepaths = mappedPathToGitItems.Where(item => item.Value != null)
                                             .Select(item => item.Key)
                                             .ToList();