Advertisement
Qrist

Create Car Class

May 16th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CarManufacturer
  4. {
  5.     class Car
  6.     {
  7.         private string make;
  8.         public string Make
  9.         {
  10.             get { return make; }
  11.             set { make = value; }
  12.         }
  13.         private string model;
  14.  
  15.         public string Model
  16.         {
  17.             get { return model; }
  18.             set { model = value; }
  19.         }
  20.         private int year;
  21.  
  22.         public int Year
  23.         {
  24.             get { return year; }
  25.             set { year = value; }
  26.         }
  27.     }
  28.     class Program
  29.     {
  30.         static void Main(string[] args)
  31.         {
  32.             Car car = new Car();
  33.             car.Make = "VM";
  34.             car.Model = "Mk4";
  35.             car.Year = 2005;
  36.             Console.WriteLine($"Make : {car.Make}\nModel : {car.Model}\nYear : {car.Year}");
  37.  
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement