Post by Admin on Jun 6, 2014 20:07:00 GMT -5
1.
using System;
class Customer
{
string _firstName;
string _lastName;
public Customer(string FirstName, string LastName)
{
this._firstName = FirstName;
this._lastName = LastName;
}
public void PrintFullName()
{
Console.WriteLine("Full Name = {0}", this._firstName + " " + this._lastName);
}
~Customer()
{
//clean up code
}
}
namespace Program
{
class Program
{
static void Main(string[] args)
{
Customer C1 = new Customer("Hieu", "Luong");
C1.PrintFullName();
}
}
}
2.
using System;
class Customer
{
string _firstName;
string _lastName;
public Customer() : this("No FirstName Provided", "No LastName Provided")
{
}
public Customer(string FirstName, string LastName)
{
this._firstName = FirstName;
this._lastName = LastName;
}
public void PrintFullName()
{
Console.WriteLine("Full Name = {0}", this._firstName + " " + this._lastName);
}
~Customer()
{
//clean up code
}
}
namespace Program
{
class Program
{
static void Main(string[] args)
{
Customer C1 = new Customer();
C1.PrintFullName();
Customer C2 = new Customer("Hieu", "Luong");
C2.PrintFullName();
}
}
}