Class Creation
using System;
namespace EmployeeDetails // Namespace is a collection of classes and is used to avoid naming conflicts.
{
class Employee
{
// Member variables
private string fname = "John";
private string lname = "Smith";
//Methods
public string getFname()
{
return fname;
}
public string getLname()
{
return lname;
}
static void Main(string[] args) // Execution starts at the main method
{
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