Home > OS >  No argument given that corresponds to the required formal parameter
No argument given that corresponds to the required formal parameter

Time:10-31

Probably a silly question but I keep getting this error

There is no argument given that corresponds to the required formal parameter 'employee' of 'Job_Form(Program.Employee, Program.Job, Program.Job, Program.Job)'

I know that is something to do with not passing parameter however then when I pass in the parameter I get another error saying Program.Employee is type that is not valid in given context

namespace company
{
    class Program
    {
        public class Employee
        {
            public Guid Id { get; set; }
            public string Name { get; set; }
            public int Age { get; set; }
            public int IQ { get; set; }
            public string CurrentJob {get;set;}
        }
        public class Job
        {
            public Guid Id { get; set; }
            public string JobDescription { get; set; }
            public int IQRequired { get; set; }
            public int Salary { get; set; }
            public bool Available { get; set; }
        }
        static void Main(string[] args)
        {      
            void Create_Jobs()
            {
                Job Job1 = new Job();
                Job1.Id = Guid.NewGuid();
                Job1.JobDescription = "CEO";
                Job1.IQRequired = 100;
                Job1.Salary = 100000;
                Job1.Available = false;

                Console.WriteLine("Jobs Avaiable \n");
                Console.WriteLine(Job1.JobDescription   "\n IQ Required  :"   Job1.IQRequired   "\nSalary :"   Job1.Salary  "\n");                
            }
            void Create_Employee()
            {
                Employee employee = new Employee();
                employee.Id = Guid.NewGuid();
                Console.WriteLine("Enter Name");
                employee.Name = Console.ReadLine();
                Console.WriteLine("Enter Age");
                employee.Age = Convert.ToInt16(Console.ReadLine());
                Console.WriteLine("Enter Age");
                employee.CurrentJob = "empty";
                Random Rnd = new Random();
                employee.IQ = Rnd.Next();
            }
            void Job_Form(Employee employee,Job Job1)
            {
                Console.WriteLine("what job Would you like:");

                if (Console.ReadLine() == "1" && (employee.IQ >= 50) && (Job1.Available == true))
                {
                    Console.WriteLine("You have been Hired");
                }
                else
                {
                    Console.WriteLine("Sorry we werent able to take you on ");
                }
            }
            Create_Jobs();
            Create_Employee();
            Job_Form(Employee employee, Job Job1);
        }
    }
}

CodePudding user response:

Don't specify argument type in method call.

Job_Form(employee, Job1);
  •  Tags:  
  • c#
  • Related