LEARN BUILD GROW TOGETHER
Practical knowledge for developers
DEVELOPER LEARNING HUB
Learn. Build. Grow Together.

Practical tutorials, real-world examples and interview preparation.

.NETC#SQL SERVERANGULAR
Home /C# /virtual vs override keyword in c#

virtual vs override keyword in c#

August 17, 2022 5 min read

 

# virtual keyword :- 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;

    }

 

#You cannot use the virtual modifier with the static, abstract, private, or override modifiers.

 

# override keyword :- The override keyword is used to extend or modify a virtual/abstract method, property, indexer, or event of base class into derived class.

 

No comments:

Post a Comment