using System.Collections.Generic;
public static void Main()
List<Patient> patients = new List<Patient>();
Patient patient1 = new Patient{Name = "Patient1"};
Patient patient2 = new Patient{Name = "Patient2"};
List<Doctor> doctors = new List<Doctor>();
Doctor doctor1 = new Doctor{Name = "Doctor1"};
Doctor doctor2 = new Doctor{Name = "Doctor2"};
Patient patient = FindObject.Find(patients, "Patient1");
Console.WriteLine("Patient Name :" + patient.Name);
Doctor doctor = FindObject.Find(doctors, "Doctor2");
Console.WriteLine("Doctor Name :" + doctor.Name);
public static class FindObject
public static T Find<T>(List<T> list, string name) where T : People, new()
return list.Find(i=>i.Name.Equals(name));
public int ParentId{ get; set; }
public string Name {get; set; }
public class Patient : People
public string PatientDescription { get; set;}
public class Doctor : People
public string DoctortDescription { get; set;}