---
title: "Interfaces"  
description: "An interface looks like a class, but has no implementation. The only thing it contains is definitions of events, indexers, methods and/or properties."  
author: "Anonymous User"  
published: 2010-07-15  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/26/interfaces  
category: ".net"  
tags: [".net"]  
reading_time: 1 minute  

---

# Interfaces

Interface looks like a class, but has no implementation. The only thing it contains is definitions of events, indexers, methods and/or properties. The reason interfaces only provide definitions is because they are inherited by classes and structs, which must provide an implementation for each interface member defined.\

##### Example

```
//defining first interface    interface Ifirst    {        void sum(int a, int b);    } //defining second interface which inherits first interface    interface Isecond:Ifirst    {        void sub(int a, int b);    } //defining class which inherits second interface     class newClass : Isecond    {//implementing interface 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());        }    }
```

##### Demonstrating u

```
//creating instance of classnewClass c = new newClass();private void btnSum_Click(object sender, EventArgs e)        {       //calling sum() of Ifirst interface     c.sum(Convert.ToInt32(txtNum1.Text), Convert.ToInt32(txtNum2.Text));        } 
```

\

![Interfaces](https://www.mindstick.com/mindstickarticle/340a0bac-c51c-4d44-bc64-25d2d51a71dd/images/e774e222-4444-4936-8cda-37aadeb8357d.png)

\

![Interfaces](https://www.mindstick.com/mindstickarticle/340a0bac-c51c-4d44-bc64-25d2d51a71dd/images/0c0e92cf-2766-45e4-aefc-00878f3b7e5d.png)

---

Original Source: https://www.mindstick.com/articles/26/interfaces

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
