C# Presentation
C# Presentation
Classes Object
String[] args: is used for command line arguments in C#. While running the C# program,
we can pass values. These values are known as arguments which we can use in the program.
class Program
{
Static void Main (String[] args)
{
System.Console.WriteLine (“Hello world”);
}
}
Output:
Hello world
Class:
Class is a group of similar objects. It is a template from which object are created. It can have
fields, methods, consturctors etc.
Simply the class is the collection of data members and the member functions it is known as
class.
Class class_name
{
//block of code
}
Object:
• Object is nothing but the real world entity, for example, chair, car, pen, mobile etc
• Object is an entity that has state and behavior. Here state means data and behavior means
functionality
• It is runtime entity, it is created at runtime.
• Object is an instance of a class. All the members of the class can be accessed through
object.
Creating an object :
Here, in the above object creation Student is a class name and S1 is a object name and in that
example Student(); this is default constructor called.
C# Object and Class Example:
using System;
public class Student
{
int id;
String name;
public static void Main (String[] args)
{
Student s1 = new Student();
s1.id=101;
s1.name=“Ramesh Gangaram”;
Console.WriteLine(s1.id);
Console.WriteLine(s1.name);
}
}
Output:
101
Ramesh Gangaram
THANK
YOU