【发布时间】:2019-10-08 10:45:37
【问题描述】:
如何从另一个使用 List<string>() 的属性设置属性?
如下图,在EnableTest1我要设置bool属性EnableTest2
为假,所以当EnableTest1 为真时它总是返回假。
public class Test
{
public List<string> _list;
public Test(List<string> list)
{
_list = list;
}
public bool EnableTest1 => _list.All(x => x == "Test1");
public bool EnableTest2 => _list.All(x => x == "Test2");
public bool EnableTest3 => _list.All(x => x == "Test3");
public bool EnableTest4 => _list.All(x => x == "Test4");
}
【问题讨论】:
-
所以您希望每个属性都有一个设置器,它基本上会覆盖您在代码中的行为?
标签: c# properties