I am new to C #. I have a Person class and a User class that inherits from the Person class. I have my console inject users into an array. Then I can add a note to the user in the users array by just entering the user ID. In my Persons class, I have this function that should look for whether this user is in an array of users.
public static Persons FindPerson(Persons[] persons, int noteid) { foreach (Persons person in persons) if (person.ID == noteid) return person; return null; }
In my User class, I have a function that processes all the input of the identifier until it gets the identifier that is in the users array.
public static User SelectUser(User[] users) { while (true) { Console.Write("Please enter the User id: "); string input = Console.ReadLine(); int id; if (int.TryParse(input, out id)) { Persons person = Persons.FindPerson(users, id); if (person != null) return person;
Everything works fine, except that now I get this error message in the "returned person" in the if statement.
It is not possible to implicitly convert the type 'UserCustomerNotes.Persons' to 'UserCustomerNotes.User'. Explicit conversion exists (are you skipping listing?)
Can anybody help? Thanks in advance.
source share