constructor in c#

PHOTO EMBED

Tue Jul 05 2022 21:53:28 GMT+0000 (UTC)

Saved by @m_azeem #c#

class Car
    {
        public Car(string Name, string Model, int Seat_Number, int Door_Number, double Price)
        {
            name = Name;
            model = Model;
            seat_Number = Seat_Number;
            door_Number = Door_Number;
            price = Price;
        }
 }


---------------------------
  internal class User
{
  private string name;
  private int age;
  //constructor
  public User(string name, int age)
  {
    this.name = name;
    this.age = age;
  }
  //getters
  public String GetName() { return name; }
  public int GetAge() { return age; }
}


//////main class//////

internal class Program
{
  static void Main(string[] args)
  {
    Program program = new Program();  
    program.PrintAge();
  }
  void PrintAge()
  {
    User me = new User("The Bad Programmer", 17);
    Console.WriteLine("\nmy name is " + me.GetName() + " and i am " + me.GetAge() +" yo");
  }
}
content_copyCOPY