我有一类像以下:我将如何使用其他类的以下静态变量?
public class Trainee
{
private static int numberOfTrainee = 30;
private string traineeName;
private string tarineeId;
}
现在我要访问的静态数据“numberOfTrainee”在下面的类,而无需创建“见习”类的对象,我不想写getter方法“numberOfTrainee”。因为,静态成员只能使用“。”。运营商。
public class TraineeUI : Form
{
private void showButton_Click(object sender, EventArgs e)
{
// I want to access "numberOfTrainee" here. Something like following:
// MessageBox.Show("Total number of trainee is: ");
}
}
感谢Abboutt先生提出的建议。 – Towhid 2010-08-12 09:53:28