本文介绍了内部LINQ和Lambda表达式之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 IList <   ResponseDTO  >  MyList =新列表<   ResponseDTO  > ();
var myValue = MyList.Select(T => T.KeyId);
var myValue =来自MyList中的myListValue
              选择myListValue.KeyId; 



在上面的代码中,第一个是Lambda Expression&第二个是LINQ,两者都给我相同的结果.

我想知道这两者之间的内部差异以及它们的性能. . ResponseDTO 替换为string ,并且ToUpper 方法用于编译代码.

 IList< string> MyList =  List< string>();
     var  myValue = MyList.Select(T = >  T.ToUpper());

//  IL_0001:newobj System.Collections.Generic.List< System.String> .. ctor 
//  IL_0006:stloc.0 
//  IL_0007:ldloc.0 
//  IL_0008:ldsfld UserQuery.CS 




IList<ResponseDTO> MyList = new List<ResponseDTO>();
var myValue = MyList.Select(T => T.KeyId);
var myValue = from myListValue in MyList
              select myListValue.KeyId;



In the above code the first one is a Lambda Expression & second is LINQ and both give me the same result.

I want to know the internal difference between these two and their performance.

解决方案




这篇关于内部LINQ和Lambda表达式之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 08:34
查看更多