我想声明一个静态变量,并在每次创建该类的对象时递增它。我正在使用C#
并且是新手。
public class student
{
static int idcount; /// for the number of objects created and to use it to assign lib nos
public info biodata; /// for making biadata easily available for both students and teachers
record rec;
public student(int i) ///// ******* parameterised constructor for adding entry
{
rec = new record();
biodata = new info(); //// new student record so everything is empty
idcount++; /// new object created so incrementing static variable
biodata.regno = idcount;
rec.limit = 0; /// indicating the number of books he has issued
}
public int getidcount()
{ return idcount; }
public student() /////local constructor for reading objects from file
{
rec = new record();
biodata = new info();
rec.limit = 0;
}
/// methods
}