Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
The Error showing this line (base(lectureId,name) )..why?

C#
namespace XYZ_System
{
    class FullTimeLectureClass : Lecturer
    {

        private double basicSalary;

        public Double _basicSalary
        {
            get { return basicSalary; }
            set { basicSalary = value; }
        }


        private Double allowance;

        public Double _allowance
        {
            get { return allowance; }
            set { allowance = value; }
        }
        
       public FullTimeLectureClass():base(){ }


        public FullTimeLectureClass(Double basicsalary):base(lectureId,name) 
        {
            this._basicSalary = basicsalary;
            this._allowance = GetAllowance();

        }




this is my base class
C#
namespace XYZ_System
{
    public class Lecturer
    {

        private int lectureId;

        public int _lectureId
        {
            get { return lectureId; }
            set { lectureId = value; }
        }

        private String name;

        public String _name
        {
            get { return name; }
            set { name = value; }
        }

        private String email;

        public String _email
        {
            get { return email; }
            set { email = value; }
        }

        private int mobileNo;

        public int _mobileNo
        {
            get { return mobileNo; }
            set { mobileNo = value; }
        }


        private int landNo;

        public int _landNo
        {
            get { return landNo; }
            set { landNo = value; }
        }

        private String status;

        public String _status
        {
            get { return status; }
            set { status = value; }
        }

        private String address;

        public String _address
        {
            get { return address; }
            set { address = value; }
        }

        private String gender;

        public String _gender
        {
            get { return gender; }
            set { gender = value; }
        }


        private Double salary;

        public Double _salary
        {
            get { return salary; }
            set { salary = value; }
        }


       
        //constrator

        public Lecturer()
        {
     
        }
       public Lecturer(int id) //Custom Constructor - overloaded 
       {
           this.lectureId = id;
       }

        public Lecturer(int lectureId, String name, String email, int mobileNo, int landNo, String status, String address, String gender, Double salary)
        {
            this.lectureId = lectureId;
            this.name = name;
            this.email = email;
            this.mobileNo = mobileNo;
            this.landNo = landNo;
            this.status = status;
            this.address = address;
            this.gender = gender;
            this.salary = salary;
        }


What I have tried:

i have created base class and child class.. there is an error showing in child class.the errors in this line

public FullTimeLectureClass(Double basicsalary):base(lectureId,name)
Posted
Updated 19-May-16 9:51am
v2
Comments
Patrice T 20-May-16 14:07pm    
And you have plan to tell what are the error messages ?
By the way, I have solutions :-)
Rifath apps 21-May-16 12:57pm    
ya i got the answer... thank you.. sir.. and also can u give ur way of answer..Error 'XYZ_System.Lecturer.lectureId' is inaccessible due to its protection level

1 solution

Quote:
base(lectureId,name)

There isn't such a constructor (taking two arguments) in your base class.
 
Share this answer
 
Comments
Rifath apps 19-May-16 15:58pm    
yes..if i insert more argument itz showing errors
CPallini 19-May-16 16:05pm    
You either provide, in your base class, a constructor accpeting the two arguments or use, in your derived class, one of the base class available contructors.
Rifath apps 19-May-16 16:21pm    
the Error showing like this : Error 'XYZ_System.Lecturer.lectureId' is inaccessible due to its protection level
Rifath apps 19-May-16 15:59pm    
may i need to insert all arguments from base class?
Sergey Alexandrovich Kryukov 19-May-16 17:38pm    
You should think not in terms of formal recipes, but in terms of rationale.
Let's say, some members are set based on some constructor parameters. If some parameter is missing, where the initialization would come from?

Remember that .NET is inherently safe. There is no room for garbage in memory.

—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900