s

C# class edit button Edit

author
Rakesh Kumar Sutar | calendar 20 January 2021 | 2095

Introduction

C# is associated with classes and objects, along with its attributes and methods. For example: in real life, a car is an object. The car has attributes, such as weight and color, and methods, such as drive and brake. A Class is like an object constructor, or a "blueprint" for creating objects.

Example

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hello_World
{
    class Program
    {
        string color = "red";

        static void Main(string[] args)
        {
            Program myObj = new Program();
            Console.WriteLine();
            Console.WriteLine("\t"  myObj.color);
            Console.ReadLine();
        }
    }
}

Output