• Source
    1. using System;
    2.  
    3. namespace ConsoleApplication2
    4. {
    5. class Program
    6. {
    7.  
    8. static void Main(string[] args)
    9. {
    10. //Object 1
    11.  
    12. var p1 = new Person
    13. {
    14. FullName = "Le Minh Tuan",
    15. Age = 26,
    16. Address = "Da Nang, Viet Nam"
    17. };
    18.  
    19. p1.ShowInfo();
    20.  
    21. //Object 2
    22. var p2 = new Person("Le Khanh Tung", 27, "Da Nang, Viet Nam");
    23. p2.ShowInfo();
    24.  
    25. //Object 3
    26. var p3 = new Person("Nguyen Van A");
    27. p3.ShowInfo();
    28.  
    29. Console.ReadLine();
    30. }
    31. }
    32.  
    33. class Person
    34. {
    35. public string FullName;
    36. public int Age;
    37. public string Address;
    38.  
    39. //Constructor 1
    40. public Person()
    41. {
    42. //Default Constructor
    43. }
    44.  
    45. //Constructor 2
    46. public Person(string fullName, int age, string address)
    47. {
    48. FullName = fullName;
    49. Age = age;
    50. Address = address;
    51. }
    52.  
    53. //Constructor 3
    54. public Person(string fullname)
    55. {
    56. FullName = fullname;
    57. Age = 30;
    58. Address = "Viet Nam";
    59. }
    60. public void ShowInfo()
    61. {
    62. Console.WriteLine(" Name:{0} \n Age: {1} \n Address: {2}", FullName, Age, Address);
    63. }
    64. }
    65. }