In: Computer Science
Patient.cs :
//namespace
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//application namespace
namespace ConsoleApp_Patient
{
class Patient //C# class
{
//private fields for patientid, lastname,firstname, age, and
email.
private int patientid;
private string lastname;
private string firstname;
private int age;
private string email;
//public data items for each of these private fields with get
and
//set methods
public int PatientID //Public field for patientid
{
get { return patientid; }
set
{
patientid = value;//set patinetid
}
}
public string LastName //Public field for lastname
{
get { return lastname; }
set
{
lastname = value.ToUpper();//set lastname in upper case
}
}
public string FirstName //Public field for firstname
{
get { return firstname; }
set
{
firstname = value;//set firstname
}
}
public int Age //Public field for age
{
get { return age; }
set
{
age = value;//set age
}
}
public string Email //Public field for email
{
get { return email; }
set
{
email = value;//set email
}
}
}
}
----------- WRITE IN C# -------------------
Modify the main class in the patient application to include a display method that has a parameter to pass a patient object and display its content.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp_Patient
{
        class Patient{
        
                private int patientid;
                private string lastname;
                private string firstname;
                private int age;
                private string email;
                public int PatientID {
                        get { return patientid; }
                        set { patientid = value; }
                }
                public string LastName {
                        get { return lastname; }
                        set { lastname = value.ToUpper(); }
                }
                public string FirstName {
                        get { return firstname; }
                        set { firstname = value; }
                }
                public int Age {
                        get { return age; }
                        set { age = value; }
                }
                public string Email {
                        get { return email; }
                        set { email = value; }
                }
    public static void display(Patient patient){
        Console.WriteLine("FirstName : "+patient.FirstName);
        Console.WriteLine("LastName  : "+patient.LastName);
        Console.WriteLine("Age       : "+patient.Age);
        Console.WriteLine("Email     : "+patient.Email);
    }
    static void Main(string[] args) {
        Patient p = new Patient();
        p.FirstName = "Mark";
        p.LastName = "Clarkin";
        p.Age = 42;
        p.Email = "trysampleMail";
        display(p);
    }
        }
}
Code & Output Screenshots :

