using System.Collections.Generic;
public static void Main(string[] args)
List<UserDetails> doctorList = new List<UserDetails>();
doctorList.Add(new Doctor { ID = "D1", Name = "Mohan", Type = "Doctor" });
doctorList.Add(new Doctor { ID = "D2", Name = "Prasath", Type = "Doctor" });
doctorList.Add(new Doctor { ID = "D3", Name = "Vignesh", Type = "Doctor" });
doctorList.Add(new Doctor { ID = "D4", Name = "Kumar", Type = "Doctor" });
doctorList.Add(new Doctor { ID = "D5", Name = "Nisha", Type = "Doctor" });
List<UserDetails> patientList = new List<UserDetails>();
patientList.Add(new Patient { ID = "P1", Name = "Madhavi", Type = "Patient" });
patientList.Add(new Patient { ID = "P2", Name = "Siddhu", Type = "Patient" });
patientList.Add(new Patient { ID = "P3", Name = "Aravind", Type = "Patient" });
patientList.Add(new Patient { ID = "P4", Name = "Naveen", Type = "Patient" });
patientList.Add(new Patient { ID = "P5", Name = "Abul", Type = "Patient" });
Console.WriteLine("---Doctor List---");
Console.WriteLine("ID" + "\t" + "Name" + "\t" + "Type");
foreach (var Doctor in doctorList)
Console.WriteLine(Doctor.ID + "\t" + Doctor.Name + "\t" + Doctor.Type);
Console.WriteLine("---Patient List---");
Console.WriteLine("ID" + "\t" + "Name" + "\t" + "Type");
foreach (var Patient in patientList)
Console.WriteLine(Patient.ID + "\t" + Patient.Name + "\t" + Patient.Type);
Console.WriteLine("\n Please enter a Name to want search:");
string Name = Console.ReadLine();
var doc = FinderObject.Find(doctorList, Name);
var pat = FinderObject.Find(patientList, Name);
Console.WriteLine("\n" +"Doctor Details: "+ (!string.IsNullOrEmpty(doc) ? doc.ToString() : "Doctor does Not Found in such name") + "\n");
Console.WriteLine("Patient Details: "+(!string.IsNullOrEmpty(pat) ? pat.ToString() : "Patient does Not Found in such name") + "\n");
public string ID { get; set; }
public string Name { get; set; }
public string Type { get; set; }
class Patient : UserDetails { }
class Doctor : UserDetails { }
static class FinderObject
public static string Find(List<UserDetails> Data, string Name)
string Details = string.Empty;
var result = Data.Find(x => x.Name.ToUpper() == Name.ToUpper());
Details =("ID:" + result.ID + ", Name:" + result.Name + ", Type:" + result.Type);