properties - Objects becoming null when passed to a Property in C# -


I have an abstract class employee and 2 other classes that increase (developer and manager) My problem is that whenever I make a manager

  employee man = new manager (1234567, 30, "bob", "pie")  

And try setting it in the new Developer's Manager field,

  employee codemonkey = new developer (1234568, 20, "code", "monkey", (manager) man) / Code>  

I'm getting argument execution that my manager is zero. I did some checks and whenever I try to set it up with the manager property in the constructor, then it becomes a null. Why am I getting this error, any advice about this would be greatly appreciated. TIA!

The code for each is below:

// Employee Class

  Public Abstract Class Staff {string firstName, lastName; Ent ID, Year Deployed; // name must be empty-empty public string FirstName {get {return firstName; } Set {if (! Value.Equals ("")) {firstName = value; } Then leave the new argument exception ("name can not be empty"); }} Public String LastName {get {return lastName; } Set {if (! Value.Equals ("")) {lastName = value; } Then leave the new argument exception ("name can not be empty"); }} Id / id should be exactly seven digits of string Public IIT ID {Return ID; } Set {if (value.ToString (). Length == 7) {id = value; } And leave the new argument exception ("ID must contain 7 digits"); }} // Should always be non-negotiable in planned years Public int year is employed ({return year gets employment;} set {if (value> = 0) {yearsEmployed = value;} Then release new argument Exceptions ("The planned year should be non-negative");}} // Constructor public employee (Int id, int year empire, string first name, string last name) {this.FirstName = firstName; This.LastName = lastName; This .ID = ID; This deployed employment posted in years;} Public Summary Intel GatewellWeb Get the Public String GetTitle {get}} Public String GetFullTitle {GetTitle + "" + GetLevel;}}}  

// Developer Category:

  public class developer: employee {manager manager; // manager can not be empty public manager {{return manager;} set {if (manager! = Null) {manager = value;} and new Excerpt Exception ("Manager can not be empty");}} // Constructor public developer (int id, int yearsEployed, stri Ng firstname, string lastname, manager manager): base (id, yearsEployed, firstname, lastname) {Console.WriteLine ("manager is empty:" + manager! = Zero); // It's right here. Manager = manager; The public override int getlevel {get (this .yr empire + 1) / 3;}} the public override string GetTitle {get {return "developer";}}}   

Do not want to say:

  If (manager! = Zero)  

  instead of  

The manager field will be started to clear. The value keyword represents the data that the asset is being sent to.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -