Class

A class is a blueprint. The blueprint is used to create objects in C#.

Example of the CAR class in C#:

using System;

namespace SimpleClasses
{
    class Program
    {
        static void Main(string[] args)
        {
            Car myCar = new Car();  //new object created from Car class
            myCar.Make = "Chevy";
            myCar.Model = "Impala";
            myCar.Year = 2015;
            myCar.Color = "Red";

            Console.WriteLine("{0} {1} {2} {3}", 
                myCar.Make, 
                myCar.Model, 
                myCar.Year, 
                myCar.Color);
        }
    }

    class Car //Car class
    {
        public string Make { get; set; }
        public string Model { get; set; }
        public int Year { get; set; }
        public string Color { get; set; }

    }
}

Back to MAIN CSHARP PAGE