Horje
constructor c# Code Example
constructor c#
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");
  }
}
Constructor in 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;
        }
 }




Csharp

Related
alphabet string[] c# Code Example alphabet string[] c# Code Example
c# last char in string Code Example c# last char in string Code Example
unity 2d player move Code Example unity 2d player move Code Example
difference two list c# Code Example difference two list c# Code Example
c# get month number Code Example c# get month number Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8