21 Sep 2017

What is class and object in c sharp with example


Object are just like reference pointer.

Object are the basic run-time entity in an object oriented programming language. 

c# in create the object with new operator.

Object is used to allocate the memory according to blueprint(Class).

Syntax:-

(Rock r = new Rock();)//Allocate the memory//


Example of Class and Object:-


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

namespace What_is_object_in_c_sharp
{
    class Program
    {
        int Empid;
        string Emp_Name;
        static void Main(string[] args)
        {
            Program P1 = new Program();
            P1.Empid = 100;
            P1.Emp_Name = "Rock Programmer";
            Console.WriteLine(P1.Empid);
            Console.WriteLine(P1.Emp_Name);
            Console.ReadKey();
        }
    }
}
output is:-



No comments:
Write comments

Contact Form

Name

Email *

Message *

© 2014 Rock Programmer . Designed by Bloggertheme9
Powered by Rock Programmer.