# What is Class, Object, Properties ?
@ Just follow the example:
Person - Class
Utpal, Tirtha (Just any name) - Object
Age, Height, Hair color - Properties
(( Any Person may be Utpal or Tirtha . And they have following properties Like as age, height, hair color etc))
@ How can you apply class , object , properties in C# (Just in console mode)
Remember:
1) Create a Class (Class include variable , methods etc [properties] )
2) Create a object by using class name.
[ Syntex: class name object name = new class name() ; ]
3) Access all properties, methods by using object
[ Syntex: object name . variable ; object name . method ; ]
Tips: Just open C# and apply this code in console mode ( you can copy the code & place it)
Example 1:
using System;
class utpal
{
static void Main(string[] args)
{
Console.WriteLine("A simple Console Program");
Console.Read();
}
}
Example 2 :
using System;
class Utpal
{
static void Main(string[] args)
{
person tirtha1 = new person();
tirtha1.info();
Console.Read();
}
}
class person
{
int age=10;
string name= "Tirtha ";
public void info()
{
Console.WriteLine(age);
Console.WriteLine(name);
}
}
No comments:
Post a Comment