---
title: "Why is the virtual keyword used in code?"  
description: "Why is the virtual keyword used in code?"  
author: "Sumit Kesarwani"  
published: 2014-08-27  
updated: 2020-09-21  
canonical: https://www.mindstick.com/interview/2056/why-is-the-virtual-keyword-used-in-code  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Why is the virtual keyword used in code?

The virtual keyword is used while defining a class to specify that the methods and the properties of that class can be overridden in derived classes.

## Answers

### Answer by Sumit Kesarwani

The virtual keyword is used while defining a class to specify that the methods and the properties of that class can be overridden in derived classes.


---

Original Source: https://www.mindstick.com/interview/2056/why-is-the-virtual-keyword-used-in-code

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
