这在asp .net MVC中意味着什么? ? x => x.Id == 1? [英] what does this mean in asp .net MVC ? ? x => x.Id == 1 ?
本文介绍了这在asp .net MVC中意味着什么? ? x => x.Id == 1?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
x => x.Id == 1如何评估?
x => x.Id ==1 how is this evaluated ?
推荐答案
如果项目的ID为1,则评估为真。
It will evaluate to true if the Id of the item is 1.
public class MyData
{
public int Id { get; set; }
public string Name { get; set; }
}
List<MyData> data = new List<MyData>
{
new MyData{ Id = 1, Name="One" },
new MyData{ Id = 2, Name="Two" },
new MyData{ Id = 3, Name="Three" }
};
IEnumerable<MyData> temp = data.Where(x => x.Id == 1);
// temp will have all MyData items in data where the Id is 1
foreach(MyData d in temp)
{
System.Diagnostics.Debug.WriteLine(d.Name);
}
你好,
这叫做Lamda Expression。这个'=> '意味着'去'。然后调用方法或动作或功能。有关Lamda Expression的更多详情,请参阅
1. Link1 >
2. Link2
3. Link3 >
谢谢
Hello ,
That is called Lamda Expression . This' => 'means 'goes to' . and after that Invoke a method or action or Function . For more details on Lamda Expression refer
1. Link1
2. Link2
3. Link3
Thanks
x => x.ID == 1表示lamda表达式。
Asp.net或MVC不同,Lamda表达式是不同的东西。
但我们使用lamda表达式和Model类。
x=>x.ID==1 denotes lamda expressions.
Asp.net or MVC is differ and Lamda expression is different thing.
But we use lamda expression with Model classes.
这篇关于这在asp .net MVC中意味着什么? ? x => x.Id == 1?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文