In the sample program we have come across a statement "using System"

using System;

Here using is a keyword used to include the namespaces in the program. Keywords r reserved words which have special meaning. Here using System declares that you can refer to the class defined in the namespace without using the fully qualified name. A program can include multiple using statements.

class Keyword

The class keyword is used to declare a class . The braces ,known as delimeters ,are used to indicate the start and end of class body.

Member variables

variables are used to store data. These r also called as date members of a class or instance members of a class. These variables r declared with the suitable data types.

Member functions

A function is a set of statements that perform a specific task in response to a message . Member functions of a class r declared inside the class.

Instantiating a class

To create memory for a class we generally use the system of dynamic allocation in C#.(i.e by using the keywords new and delete). so to allocate memory to a class we take help of objects which act as instance for the class . These objects interact with each other by passing messages and by responding to received messages. Objects use methods to pass messages, the task of passing messages is done by using member functions. all the objects of a class will use the same copy of member functions through out but they use different copy of member variables in memory.

eg: Student std=new Student();

here 'std' is the object of class Student where memory is allocated dyanamically using the keyword new.
we can access the member functions using this object 'std' .

eg:
std.Accept();
std.Display();

0 Comments:

Post a Comment



Newer Post Older Post Home