我有一小段代码:
public DisabledStudent(int id, int age, bool requiressupport)
{
this.requiressupport = requiressupport;
}
数组类似于下面的:
public partial class Form1 : Form
{
const int MaxStudents = 4;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Student[] studentList;
studentList = new Student[4];
studentList[0] = new Student(51584, 17);
studentList[1] = new Student(51585, 19);
studentList[2] = new Student(51586, 15);
studentList[3] = new Student(51587, 20);
for (int i = 0; i < MaxStudents; i++)
{
lstStudents.Items.AddRange(studentList);
}
}
我想要做的是从一组学生中输出一个字符串,并根据requiressupport
布尔值是true
或基本上显示文本的不同部分false
:
public override string ToString()
{
return string.Format("Disabled Student - ID: {0} (Age {1})", this.Number, this.Age);
}
我希望上面的语句基本上说明boolean 是否为Disabled Student - ID: 45132 (Age 19) with support
以及boolean是否为,但我不确定我会怎么做?requiressupport
true
Disabled Student - ID: 45132 (Age 19) without support
requiressupport
false