C#
class Book
{
// class field
protected string Name;
// class method
public void SetName(string Name)
{
this.Name = Name;
}
}
class Program
{
static void Main(string[] args)
{
// create a class object Book
Book book1 = new Book();
book1.SetName("Harry Potter");
// book1.Name = "Harry Potter"
}
}
C#
class Book
{
protected string Name;
protected int Price;
public Book(string name) : this(20)
{
Name = name;
}
public Book(int price)
{
Price = price;
}
}
class Program
{
static void Main(string[] args)
{
Book book1 = new Book("Wizard of the Sea");
// book1.Name = "Wizard of the Sea"
// book1.Price = 20
}
}