GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  Microsoft  >  ASP.NET
Go To First  |  Previous Question  |  Next Question 
 ASP.NET  |  Question 160 of 163    Print  
Virtual function in c#
explain virtual function in c# with an example


  
Total Answers and Comments: 2 Last Update: October 01, 2008     Asked by: isaacsundarsingh 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: bb.geetha
 
Virtual functions implement the concept of polymorphism are the same as in C#, except that you use the override keyword with the virtual function implementaion in the child class. The parent class uses the same virtual keyword. Every class that overrides the virtual method will use the override keyword.

class Shape
{
public virtual void Draw()
{
Console.WriteLine("Shape.Draw") ;
}
}

class Rectangle : Shape

{
public override void Draw()
{
Console.WriteLine("Rectangle.Draw");
}
}




Above answer was rated as good by the following members:
rajanikanth99488, ponvanaraja, YordanGeorgiev, mukta1902
June 06, 2008 02:47:45   #1  
bb.geetha Member Since: May 2008   Contribution: 8    

RE: Virtual function in c#
Virtual functions implement the concept of polymorphism are the same as in C#, except that you use the override keyword with the virtual function implementaion in the child class. The parent class uses the same virtual keyword. Every class that overrides the virtual method will use the override keyword.

class Shape
{
public virtual void Draw()
{
Console.WriteLine("Shape.Draw") ;
}
}

class Rectangle : Shape

{
public override void Draw()
{
Console.WriteLine("Rectangle.Draw");
}
}



 
Is this answer useful? Yes | NoAnswer is useful 4   Answer is not useful 0Overall Rating: +4    
October 01, 2008 21:14:11   #2  
ynvpavan Member Since: September 2007   Contribution: 16    

RE: Virtual function in c#
Virtulal function can not be instatntiated. Declaring a function as virtual tells the compiler that this function is being overrided by the child one's
 
Is this answer useful? Yes | No

 Related Questions

The Concept of Project exists in VS 2005 but is supports multiple ways to open websites. Unlike in VS2005, paper can be opened using Front Page serer extensions, FTP or a direct file system path, existing 
View Question | Asked by : bicu

When opening a project file explicitly open it from an existing virtual directory. 
Latest Answer : Use Trusted connection. Or Give Ip address of the system where IIS is running in dotnet code... ...
Read Answers (1) | Asked by : bicu

When we click a button on webform it shows java script which function is used to show thisthanks friends ambica kiran kumar.majji
Read Answers (1) | Asked by : ambica kiran

explain virtual function in c# with an example 
Latest Answer : Virtulal function can not be instatntiated. Declaring a function as virtual tells the compiler that this function is being overrided by the child one's ...


 Sponsored Links

 
Related Articles

Online Virtual Business Network

How to begin an Online Virtual Business Network What is Virtual Business Network Business and commerce right from the ancient days depended a lot on the physical representation of the business and the physical identity of the customers and other collaborators Most of the business dealings were done
 

Agility in Virtual Business Networks

Agility in Virtual Business Networks Agility means responding to rapid changes and continuous change management With the rapid economic changes and unexpected market behavior the virtual business networks have to adapt themselves to be able to respond in a timely and fast manner Therefore agility pr
 

Creating Virtual Business Network

Requirements of Virtual Business Network The sudden expansion of electronic commerce has resulted in many changes in the way business is done globally The virtual business network is the buzz word among the business communities internet community and freelance work seekers Traditional business strat
 

Business Network Virtual Communication Tools

Business Network Virtual Communication Tools Since ages the Business community heavily relied on face to face communication for building Business relationships Face to face communications formed the basis for trust in a relationship An individual’ s appearance or the physical appearance of
 

Virtual Business Networks

Virtual Business Networks Classification of Virtual Business Networks Virtual Business Network is the most discussed topic among the Business Communities nowadays The basic definition of a Virtual Business Network means a group of small Businesses joining together to collaborate and co operate to ac
 

Collaboration in Virtual Business Networks

Collaboration in Virtual Business Networks Most common businesses are small and majority of them are home based businesses The small businesses have different common fields ranging from the traditional consumer business to technological trading Mostly these small businesses have been responsible for
 

C++ Pure Virtual Function and Base Class

C Pure Virtual Function and Virtual Base Class In this C tutorial you will learn about pure virtual function declaration of pure virtual function and virtual base class virtual base class and how to implement a virtual base class explained with examples mosgoogle center What is Pure Virtual Function
 

C++ Virtual Functions

C Virtual Functions What are Virtual Functions Virtual as the name implies is something that exists in effect but not in reality The concept of virtual function is the same as a function but it does not really exist although it appears in needed places in a program The object oriented programming la
 

C++ Function Passing Types

C Function Passing Types In this C tutorial you will learn about function passing types two types of arguments passing in functions passed by value  and  passed by reference are discussed here mosgoogle center The arguments passed to a function can be performed in two ways Passed
 

What is DECODE function used for?

DECODE is used to decode a CHAR or VARCHAR2 or NUMBER into any of several different character strings or numbers based on value. That is DECODE does a value-by-value substitution. For every value that is given in the DECODE function it makes an if then check and matches the value. The general format
 





About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape