---
title: "How can you prevent a class from overriding in C# and Visual Basic?"  
description: "How can you prevent a class from overriding in C# and Visual Basic?"  
author: "Sumit Kesarwani"  
published: 2014-08-27  
updated: 2020-09-20  
canonical: https://www.mindstick.com/interview/2066/how-can-you-prevent-a-class-from-overriding-in-c-sharp-and-visual-basic  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# How can you prevent a class from overriding in C# and Visual Basic?

You can prevent a class from overriding in C# by using the sealed keyword; whereas, the NotInheritable keyword is used to prevent a class from overriding in Visual Basic.

## Answers

### Answer by Sumit Kesarwani

You can prevent a class from overriding in C# by using the sealed keyword; whereas, the NotInheritable keyword is used to prevent a class from overriding in Visual Basic.


---

Original Source: https://www.mindstick.com/interview/2066/how-can-you-prevent-a-class-from-overriding-in-c-sharp-and-visual-basic

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
