Tuesday 6 March 2012

Use Of this keyword


// this keyword introduction
using System;
class Person
{
//Private Data Declaration
int age;
string name;

    Person()
{
Console.WriteLine("Private Constructors");
}

public Person(int age,string name)
{
this.age=age;
this.name=name;
}
public void print()
{
Console.WriteLine("Name: {0}, Age: {1}",name,age);
}
}

class Program
{
static void Main()
{

Person obj=new Person(20,"Ankur Bhatnagar");
obj.print();
}
}

No comments:

Post a Comment