Example program : -


Class Diagram:-






using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//Program for Read Write Property
namespace CAProperties
{
    class ClsEmployee
    {
        int EmpId, EAge;
        string EName, EAddress;
        public int PEmpId
        {
            set
            {
                EmpId = value;
            }
            get
            {
                return EmpId;
            }
        }
        public string PEName
        {
            set
            {
                EName = value;
            }
            get
            {
                return EName;
            }
        }
        public string PEAddress
        {
            set
            {
                EAddress = value;
            }
            get
            {
                return EAddress;
            }
        }
        public int PEAge
        {
            set
            {
                EAge = value;
            }
            get
            {
                return EAge;
            }
        }
    }
    class ClsProperty1
    {
        static void Main(string[] args)
        {
            ClsEmployee Obj1 = new ClsEmployee();
            Console.WriteLine("Enter Employee details");
            Console.WriteLine("Enter Employee id");
            Obj1.PEmpId = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter Employee Name");
            Obj1.PEName = Console.ReadLine();
            Console.WriteLine("Enter Employee Address");
            Obj1.PEAddress = Console.ReadLine();
            Console.WriteLine("Enter Employee Age");
            Obj1.PEAge = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Employee id is     :-   " + Obj1.PEmpId);
            Console.WriteLine("Employee Name is   :-   " + Obj1.PEName);
            Console.WriteLine("Employee Address is:-   " + Obj1.PEAddress);
            Console.WriteLine("Employee Age is    :-   " + Obj1.PEAge);
            Console.ReadLine();
        }
    }
}



Output :-


No comments:

Post a Comment