We hava learnt that what is object ?
Now it is important to note that we can call non-static method through object in C#.
Non-Static Method: Those method which is declare without static keyword are called non-static method.
For Ex :- public void Add() //here Add is a non static method
{
//method body
}
now see this example in which see how can we call non static method through object.
using System;
class Call
{
public void Add() //non static method
{
Console.WriteLine("This is Add method");
}
public static void Main()
{
Call obj=new Call(); //obj is object of Call class
obj.Add(); //calling Add() method through ob
}
}
//output will be
This is Add method
About Me
Monday, December 13, 2010
Subscribe to:
Posts (Atom)