Define a class with constructor,fields and properties
using System;
using System.Collections.Generic;
namespace App
{
class Car
{
private int registrationNumber;
public int RegistrationNumber
{
get { return registrationNumber; }
set { registrationNumber = value; }
}
private string model;
public string Model
{
get { return model; }
set { model = value; }
}
private string colour;
public string Colour
{
get { return colour; }
set { colour = value; }
}
private double price;
public double Price
{
get { return price; }
set { price = value; }
}
public Car()
{
}
public Car(int registrationNumber, string model, string colour, double price)
{
this.registrationNumber = registrationNumber;
this.model = model;
this.colour = colour;
this.price = price;
}
}
class Program
{
static void Main(string[] args)
{
var c1 = new Car(5646321, "Ford X5", "Red", 45000);
var c2 = new Car(7894546, "Ford X8", "Blue", 5000);
var c3 = new Car(8745565, "Reno X45", "Yellow", 95050);
Console.ReadLine();
}
}
}
Comments
Leave a comment