[英]C# Lambda in set property
通過閱讀C#示例,我發現set屬性中使用了lambda:
private bool _inProgress;
public bool InProgress
{
get {
return _inProgress;
}
set { Set(() => InProgress, ref _inProgress, value); }
}
但是它對我不起作用,我明白了
the name "Set" does not exist in current context
錯誤。
我發現這種語法{Set(() => InProgress, value);}
等於{return InProgress = value;}
正確嗎? 但是我仍然得到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.