C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Virtual Methods in C#


Posted Date: 29 Oct 2006    Resource Type: Definitions    Category: General

Posted By: DotNetGuts (DNG)       Member Level: Diamond
Rating:     Points: 4



By making a class's method as virtual, we allow the function to be overridden in any of derived class.

Example :


Class parent
{
virtual void hello() //the class can now be overriden in child
{ Console.WriteLine(“Hello from Parent”); }

void bye()
{ Console.WriteLine("Bye from Parent"); }
}

Class child : parent
{
override void hello()
{ Console.WriteLine(“Hello from Child”); }

void bye() //hiding parent's bye() method
{ Console.WriteLine("Bye from Child"); }
}

static void main()
{
parent objParent = new child();
objParent.hello(); //Hello from Child.
objParent.bye(); // Bye from Parent.
}








Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Virtual Methods in C#  .  Virtual Methods  .  Virtual Method Definition  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Microsoft Intermediate Language (MSIL)
Previous Resource: ActiveSync
Return to Discussion Resource Index
Post New Resource
Category: General


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

it support

Contact Us    Privacy Policy    Terms Of Use