Skip to main content

C# Virtual

The virtual keyword is used to modify a method, property, indexer, or event declaration and allow for it to be overridden in a derived class. For example, this method can be overridden by any class that inherits it.



public virtual double Area() 
{
    return x * y;
}



When a virtual method is invoked, the run-time type of the object is checked for an overriding member. The overriding member in the most derived class is called, which might be the original member, if no derived class has overridden the member.
By default, methods are non-virtual. You cannot override a non-virtual method.
You cannot use the virtual modifier with the staticabstract, private, or override modifiers.

Click here for more info.

Comments

Popular posts from this blog

Five free tools for managing partitions - TechRepublic

1: MiniTool Partition Wizard Free Edition As its name suggests,  MiniTool Partition Wizard Free Edition  is a free tool for creating and managing partitions. It has a clean interface and does a nice job of providing access to the most common partition-related tasks without being overly complex. 2: EaseUS Partition Master Free Edition EaseUS Partition Master Free Edition  is another free tool for creating and managing partitions. At first glance, it appears to be somewhat lightweight. Upon closer inspection, however, you'll discover that it includes some nice features, such as a disk cloning wizard and a wizard that lets you migrate an OS to an alternate location. 3: AOMEI Partition Assistant Standard Edition AOMEI Partition Assistant Standard Edition  is a free partition management tool. Its interface isn't exactly original. In fact, I had to do a double take to see whether this application was just a reskinned version of one of the other applications discussed in t...

Problem with encoding Arabic with Google Chrome on Windows 10: Text not being displayed properly

تصحيح مشكلة قرائة اللغه العربيه على جوجل كروم If you have issue of text not being displayed properly in Chrome on Windows 10, you need to flow the steps below: In the browser address bar go to the Chrome flags settings by going to the following address: chrome://flags/#disable-direct-write. Change the "Disable DirectWrite Windows" from Enable to Disable. Click on "RELAUNCH NOW"!

C# ArrayList

C# ArrayList is used when there is a need for variable size array: using System; using System.Collections; namespace ConsoleApplication1 {     class Program     {         static void Main( string [] args)         {             ArrayList List1 = new ArrayList ();             ArrayList List2 = new ArrayList ();             List1.Add( "B" );             List1.Add( "A" );             List1.Add( "C" );             Console .WriteLine( "Shows Added valuess" );            ...