---
title: "Interface in C#"  
description: "Interfaces define properties, methods, and events, which are the members of the interface. Interfaces contain only the declaration of the members. It"  
author: "Anonymous User"  
published: 2016-05-05  
updated: 2019-11-24  
canonical: https://www.mindstick.com/articles/12036/interface-in-c-sharp  
category: "c#"  
tags: ["c#", "oops", "interface"]  
reading_time: 2 minutes  

---

# Interface in C#

[Interface](https://www.mindstick.com/articles/12101/interfaces-in-java-extending-interfaces) is also a user define type but can contain only [abstract methods](https://www.mindstick.com/forum/159550/how-to-implement-an-interface-with-two-abstract-methods-by-a-lambda-expression) in it. [Interfaces](https://www.mindstick.com/articles/26/interfaces) define [properties](https://yourviews.mindstick.com/view/81845/now-it-s-possible-to-predict-properties-of-any-molecule), methods, and events, which are the members of the interface. Interfaces contain only the declaration of the members. It is the [responsibility](https://answers.mindstick.com/qa/104498/what-is-the-significance-of-the-fiscal-responsibility-and-budget-management-act) of the deriving class to define the members.

\
**Note:** We are inheriting a class from to another class but it is possible to inherit the class from an interface also where as if a class inherits from another class it is for consuming the member of [parent](https://www.mindstick.com/blog/154/how-to-find-parent-of-control-in-wpf) class but a class inheriting from interface is per implementing the members of its parent.

\
**Declaring Interfaces :** Interfaces are declared using the interface keyword. It is similar to class declaration. Interface statements are public by default. Following is an example of an interface declaration:

\
**Interface1**

```
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks; namespace OopsConcepts{   public interface  Interface1   {         void showTransaction();     double getAmount();        }}
```

[Implementation](https://answers.mindstick.com/qa/44913/who-is-the-minister-of-statistics-and-programme-implementation) of the above interface

**InterfaceTest class** \

```
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks; namespace OopsConcepts{   public class InterfaceTest:Interface1    {      private string tCode;      private string date;      private double amount;       public InterfaceTest()      {         tCode = " ";         date = " ";         amount = 0.0;      }       public InterfaceTest(string c, string d, double a)      {         tCode = c;         date = d;         amount = a;       }               public double getAmount()      {         return amount;      }           public void showTransaction()      {         Console.WriteLine("Transaction: {0}", tCode);         Console.WriteLine("Date: {0}", date);         Console.WriteLine("Amount: {0}", getAmount());      }    }}
```

InterfaceClassTest class

```
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks; namespace OopsConcepts{    class InterfaceClassTest    {        static void Main(string[]args)        {           InterfaceTest t1 = new InterfaceTest("001", "8/10/2015", 78900.00);           InterfaceTest t2 = new InterfaceTest("002", "9/10/2016", 451900.00);       }     }}
```

\

Output: 1. [Transaction](https://www.mindstick.com/blog/175/transactions-in-database)- 001

Date- 8/10/2015

Amount-78900

\

\

Output: 2. Transaction- 002

Date- 9/10/2016

Amount-451900

---

Original Source: https://www.mindstick.com/articles/12036/interface-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
