[英]how to gather all created objects of a class in a list c#
public Guna2TileButton [] topNav =
{
//this.report,
};
here there are 10 GUNA tile buttons and I want to collect them in an array to help me alter there property active button styling.. I don't want to write 10 if else statement for every button.. array will help me simplify that.. can any one help me这里有 10 个 GUNA 平铺按钮,我想将它们收集在一个数组中,以帮助我改变那里的属性活动按钮样式。我不想为每个按钮写 10 个 if else 语句。数组将帮助我简化它。 。 谁能帮我
If you already have the class instances created, you can simply include those instances within the the array initialiser:如果您已经创建了 class 实例,您可以简单地将这些实例包含在数组初始化程序中:
public Guna2TileButton[] topNav = { instance1, instance2 };
Or you can create the objects directly:或者您可以直接创建对象:
public Guna2TileButton[] topNav =
{
new Guna2TileButton() { /* Set properties here */ },
new Guna2TileButton() { /* Set properties here */ },
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.