using System; using System.Collections.Generic; using System.Linq; using System.Text; class Value { private static int i = 3; public static int i { et { return i; } } } class Main { public static void Main() { Console.WriteLine(Value.i); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; class Employee { private string fName = string.Empty; Private string lName = string.Empty; public string FirstName { get { return fName; } set { fName = value; } } public string LastName { get { return lName; } set { lName = value; } } // Here take FullName is as a virtual public virtual string FullName { get { return fName + ", " + lName; } } } class Company : Employee { // Overiding the FullName virtual property derived from employee class Public override string FullName { get { return "Mr. " + FirstName + " " + LastName; } } } class Main { public static void Main() { Company CompanyObj = new Company(); CompanyObj.FirstName = "Satish"; CompanyObj.LastName = "Reddy"; Console.WriteLine("Employee Full Name is : " + CompanyObj.FullName); } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; abstract class Employee { private string fName = string.Empty; private string lName = string.Empty; public string FirstName { get { return fName; } set { fName = value; } } public string LastName { get { return lName; } set { lName = value; } } } // FullName is abstract public abstract string FullName { get; } } class Company: Employee { // Overiding the FullName abstract property derived from employee class public override string FullName { get { return "Mr. " + FirstName + " " + LastName; } } } class Main { public static void Main() { Company CompanyObj = new Company(); CompanyObj.FirstName = "Satish"; CompanyObj.LastName = "Reddy"; Console.WriteLine("Employee Full Name is : " + CompanyObj.FullName); } }