cool thanks again ArekBulski,
Last question:
Here is the code below,
The questions are, am I just removing the variables from whatever the user specifies example (if user wants to remove user 1, they type in user 1 and it removes all of user 1 info) which does that happen in this code, or am I just removing whats in the list and not the key? I am also getting an error message saying "No overload for method 'removeitem' takes '1' argument", I know i did it right because the removeitem (which is found in the employee class) has 3 in its parameters which contains 2 strings and 1 int, shouldnt it not get that error message anyways, but most importantly, am I using the removing method correctly to remove the user information and the key variable so the other variables can move up?
code:
main code:
class Program
{
static void Main(string[] args)
{
string name2,name3;
int age4;
employee employeeremoval = new employee(name2, name3, age4);
List<employee> employeedisplay = new List<employee>();
string answer;
Console.WriteLine("would you like to enter employee information?");
answer = Console.ReadLine();
while (answer.ToLower() != "yes" && answer.ToLower() != "no")
{
Console.WriteLine("Please answer yes or no");
answer = Console.ReadLine();
}
while (answer.ToLower() == "yes")
{
string name1, lastname1, answer1;
int age, numanswer1;
Console.WriteLine("Please type in first name:");
name1 = Console.ReadLine();
Console.WriteLine("Please type in last name:");
lastname1 = Console.ReadLine();
Console.WriteLine("Type in Age:");
age = Convert.ToInt32(Console.ReadLine());
employee employeeform = new employee(name1, lastname1, age);
Console.WriteLine("would you like to enter employee information?");
answer = Console.ReadLine();
employeedisplay.Add(new employee(name1, lastname1, age));
Console.WriteLine("Here are the added employess");
foreach (employee employeethis in employeedisplay)
{
Console.WriteLine(employeethis.shownames());
}
Console.WriteLine("Who would you like to remove?");
answer1 = Console.ReadLine();
if (answer1.ToLower() != "yes" && answer1.ToLower() != "no")
{
Console.WriteLine("Good bye");
}
if (answer.ToLower() == "yes")
{
foreach (employee employment in employeedisplay)
{
Console.WriteLine(employment.shownames());
}
Console.WriteLine("Who would you like to remove? type number if of the person you want to remove");
numanswer1 = employeeremoval.removeitem(new employee(name1, lastname1, age));
while (answer.ToLower() != "yes" && answer.ToLower() != "no")
{
Console.WriteLine("Please answer yes or no");
answer = Console.ReadLine();
}
}
if (answer.ToLower() == "no")
{
Console.WriteLine("Good Bye :) ");
System.Threading.Thread.Sleep(3000);
}
}
class employee
class employee
{
private string firstname, lastname;
private int age;
public employee()
{
}
public employee(string firstname, string lastname, int age)
{
this.Firstname = firstname;
this.Lastname = lastname;
this.Age = age;
}
public string Firstname
{
get { return firstname; }
set { firstname = value; }
}
public string Lastname
{
get { return lastname; }
set { lastname = value; }
}
public int Age
{
get { return age; }
set { age = value; }
}
public string shownames()
{
return String.Format("Employee name: " + Firstname + "\nEmployee lastname: " + Lastname + "\nAge: " + Age);
}
public void removeitem(string firstname, string lastname, int age)
{
List<employee> removing = new List<employee>();
removing.Remove(new employee(firstname, lastname, age));
}
}
again sorry for all the spegehtti code, just wanted to cook something up real fast, and typing a whole bunch of methods would seem to long for me, imo, and sorry for not using PASCAL naming convention.
But any input on this what am I doing wrong and how to implement .remove to employeeremoval would be great : )
Thanks in advance