Reference Types
using System;
// Instances(Objects) of classes are known as reference types. They are allocated in heap.
class Employee
{
private string fname = "John";
private string lname = "Smith";
public string getFname()
{
return fname;
}
public string getLname()
{
return lname;
}
static void Main(string[] args)
{
Employee e = new Employee(); // Creating the object of class
String first_name = e.getFname();
String last_name = e.getLname();
Console.WriteLine("Name of the employee: " + first_name + " " + last_name);
Console.ReadLine();
}
}
Output:
Name of the employee: John Smith