using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ClassofEmployees
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
class employee
{ //will include the attributes of all employees of your organization.
//fields for employee
public int employeeId; // 5 digit number to represent employee
public int ssn; //social security number of employee
public string name; //employee name
public int dob; //date of birth
public int pay; //rate of pay
}
class managers : employee
{
public string backgroundCheck {get; set;}
public string isSalary;
public string responsibilitys;
}
private void getEmployeeData(employee employee)
{
employee.employeeId = int.Parse(EmployeeID.Text);
employee.ssn = int.Parse(SSN.Text);
employee.name = employeeName.Text;
employee.dob = int.Parse(DOB.Text);
employee.pay = int.Parse(pay.Text);
managers.backgroundCheck = bCYes;
managers.isSalary = salaryYes;
managers.responsibilitys = responsibilitys.Text;
}
private void add_Click(object sender, EventArgs e)
{
//create new employee object
employee newemployee = new employee();
//get employee data
getEmployeeData(newemployee);
//add employee data to new form window list
}
Okay I am completely lost on the error I am receiving. I am following an example in my text book.
This is the error I receive:
Error 1 An object reference is required for the non-static field, method, or property 'ClassofEmployees.Form1.managers.BCY.get' C:\Users\T-Ali\Desktop\SHawnasschool\vb.net 2 c#\projects\ClassofEmployees\ClassofEmployees\Form1.cs 59 13 ClassofEmployees
What I understand is that the object is not created. However The object I believe I created with this line of code:
//create new employee object
employee newemployee = new employee();
//get employee data
getEmployeeData(newemployee);
//add employee data to new form window list
why does employee.name or any of the employee.something work, but the manager part wont? how can I fix this?