i have created a class and with that class i passed constructor and then i made that class abstract class, but when i want to get 1 attribute of the abstract class from the inherit class it showing some error can not take argument 0
public class Device1
{
public int dwMachineNumber;
public int dwBaudrate;
public int dwCommPort;
public string dwIPAddress;
public int dwPort;
public int dwPassWord;
public Device1(int dwMachineNumber)
{
this.dwMachineNumber = dwMachineNumber;
}
public Device1(int dwMachineNumber, int dwBaudrate, int dwCommPort, string dwIPAddress, int dwPort, int dwPassWord)
{
this.dwMachineNumber = dwMachineNumber;
this.dwBaudrate = dwBaudrate;
this.dwCommPort = dwCommPort;
this.dwIPAddress = dwIPAddress;
this.dwPort = dwPort;
this.dwPassWord = dwPassWord;
}
}
public class EnableMachine : Device1
{
public int Device_Busy; //if 0 busy and 1 not busy
public EnableMachine(int dwMachineNumber, int Device_Busy)
{
this.Device_Busy = Device_Busy;
this.dwMachineNumber = dwMachineNumber;
}
}
Try this:
EDIT:
When calling the constructor of a derived class, it also tries to call the constructor of the base class. Since you just had:
it by default tries to call the parameterless constructor
Device()but Device1 does not have a parameterless constructor; hence the error “..does not contain a method accepting 0 arguments”.You need to tell it to use the constructor accepting the dwMachineNumber argument by adding the line
to your derived class’s constructor. So, effectively, when you instantiate the derived class, it takes the dwMachineNumber argument and trunks it through to the base class’s constructor.