using System;
public class Person
{
// Field
private string name;
// property
public string NAME // indirect access: with the {} bracket
get
return name;
}
// Constructor that takes no arguments.
public Person()
name = "unknown";
// Constructor that takes one argument.
public Person(string nm)
name = nm;
public static void Main()
// Call the constructor that has no parameters.
Person person1 = new Person();
Console.WriteLine(person1.name);
person1.name = "John";
// person1.NAME = "John"; // doesn't work (This property is read-only)
Console.WriteLine(person1.name); // access the field DIRECT
Console.WriteLine(person1.NAME); // acesss the property INDIRECT