Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/282.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# 浏览包含数字的对象属性_C#_Asp.net - Fatal编程技术网

C# 浏览包含数字的对象属性

C# 浏览包含数字的对象属性,c#,asp.net,C#,Asp.net,我有一个具有这些属性的对象,还有一个布尔值列表(属性类型)。 我想查看我的对象属性,并将列表中的值关联起来。 例如: 我的名单(0)是D1。 我的清单(1)是N1 我的名单(2)是D2 我的清单(3)是N2 问题是我没有7个,我有60个。 最好的方法是什么 多谢各位 public bool D1 { get; set; } public bool N1 { get; set; } public bool D2 { get; set; } public bool N2 { get; set; }

我有一个具有这些属性的对象,还有一个布尔值列表(属性类型)。 我想查看我的对象属性,并将列表中的值关联起来。 例如:

我的名单(0)是D1。 我的清单(1)是N1 我的名单(2)是D2 我的清单(3)是N2 问题是我没有7个,我有60个。 最好的方法是什么

多谢各位

public bool D1 { get; set; }
public bool N1 { get; set; }

public bool D2 { get; set; }
public bool N2 { get; set; }

public bool D3 { get; set; }
public bool N3 { get; set; }

public bool D4 { get; set; }
public bool N4 { get; set; }

public bool D5 { get; set; }
public bool N5 { get; set; }

public bool D6 { get; set; }
public bool N6 { get; set; }

public bool D7 { get; set; }
public bool N7 { get; set; }

请不要将代码作为图像发布。您可以更改对象的定义方式吗?一般来说,如果您有一组名称中带有顺序数字的属性,那么您可能做错了。几乎总是最好使用以索引为参数的对象,例如列表、数组或索引属性。在构造函数中执行一次该对象来自何处?有人真的手工写了60个属性吗?如果这是通过反序列化JSON或XML字符串实现的,则可以更改反序列化代码并以数组或列表的形式检索这些值。例如,在JSON中,您可以反序列化到一个字典而不是一个对象,并将所有对作为字典中的条目获取。这是为每个用户保存一个月中的每一天(白天和晚上)的布尔值。我手工构建对象,它保存在数据库中,然后显示在日历中。