Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将new[]与lambda一起使用 protectedoverride IEnumerable属性=>new[] { 州际关系属性 };_C#_Linq_Lambda_C# 6.0 - Fatal编程技术网

C# 将new[]与lambda一起使用 protectedoverride IEnumerable属性=>new[] { 州际关系属性 };

C# 将new[]与lambda一起使用 protectedoverride IEnumerable属性=>new[] { 州际关系属性 };,c#,linq,lambda,c#-6.0,C#,Linq,Lambda,C# 6.0,谁能解释一下这里发生了什么事。为什么我们有新的[]和lambda表达式。我第一次看到它。这不是一个匿名方法(也称为lambda表达式),而是一种以更简洁的方式编写计算属性的方法。这完全等同于 protected override IEnumerable<string> Attributes => new [] { IntercationAttributes.State }; 受保护的覆盖IEnumerable属性{ 获取{returnnew[]{interactionat

谁能解释一下这里发生了什么事。为什么我们有新的[]和lambda表达式。我第一次看到它。

这不是一个匿名方法(也称为lambda表达式),而是一种以更简洁的方式编写计算属性的方法。这完全等同于

protected override IEnumerable<string> Attributes => new []
{
  IntercationAttributes.State
};
受保护的覆盖IEnumerable属性{
获取{returnnew[]{interactionattributes.State};
}
如您所见,表单的只读属性

protected override IEnumerable<string> Attributes {
  get { return new [] { IntercationAttributes.State };
}
{get{return;}
可以写成

<property> { get { return <expression>; } }
=>;

在C#6中,稍微减少声明周围的语法。

很酷,非常感谢您的解释
<property> => <expression>;