简体   繁体   English

设定属性中的C#Lambda

[英]C# Lambda in set property

reading through c# examples i found usage of lambda in set property: 通过阅读C#示例,我发现set属性中使用了lambda:

 private bool _inProgress;
 public bool InProgress
        {
            get {
                return _inProgress;
            }
            set { Set(() => InProgress, ref _inProgress, value); }
        }

However it's not working for me, i get 但是它对我不起作用,我明白了

the name "Set" does not exist in current context

error. 错误。

i found that this syntax {Set(() => InProgress, value);} equals {return InProgress = value;} is that correct? 我发现这种语法{Set(() => InProgress, value);}等于{return InProgress = value;}正确吗? However i'm still getting the name "Set" does not exist in current context error. 但是我仍然得到the name "Set" does not exist in current context错误the name "Set" does not exist in current context

查看在哪里找到它的类,您会发现它是从另一个类继承的,因此Set可能是超类的成员,要使其正常工作,您的类也必须继承该类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM