---
title: "Interface in C#"  
description: "An interfacelooks like a class, but has no implementation. The only thing it contains isdefinitions of events, indexers, methods and/or properties.The"  
author: "Uttam Misra"  
published: 2010-12-27  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/82/interface-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Interface in C#

An interfacelooks like a [class](https://www.mindstick.com/blog/165/generic-class-in-c-sharp), but has no [implementation](https://www.mindstick.com/forum/33764/how-to-implementation-of-class-in-c-sharp). The only thing it contains isdefinitions of [events](https://www.mindstick.com/blog/102/events-in-c-sharp), [indexers](https://www.mindstick.com/interview/406/what-are-the-indexers), [methods](https://www.mindstick.com/articles/13060/runny-nose-remedy-methods-that-work-best) and/or properties.The reason [interfaces](https://www.mindstick.com/articles/12100/interfaces-in-java-real-life-example) onlyprovide definitions is because they are inherited by classes and structs,which [must](https://www.mindstick.com/articles/12978/top-reasons-why-every-magento-ecommerce-store-must-opt-for-mobile-app) provide an implementation for each [interface](https://www.mindstick.com/articles/12101/interfaces-in-java-extending-interfaces) member defined.

##### Example

```
//defining first interface    interface Ifirst    {        voidsum(int a, intb);    } //definingsecond interface which inherits first interface    interface Isecond:Ifirst    {        voidsub(int a, intb);    } //definingclass which inherits second interface     class newClass : Isecond    {//implementinginterface defined methods        public void sum(int a, int b)        {            MessageBox.Show("Sum is: " + (a + b).ToString());        }        public void sub(int a, int b)        {            MessageBox.Show("Difference is: " + (a - b).ToString());        }    }
```

---

Original Source: https://www.mindstick.com/blog/82/interface-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
