Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# - Interface inside a class

Tags:

c#

According to the MSDN document interface can be a member of a class or namespace :

for Example i can declare:

public class Test
{
    public interface IMemberofTest
    {
        void get();
    }
}

What is the use of having interface inside a class? Won't it break the purpose of real interface usage?

like image 840
user160677 Avatar asked Dec 18 '22 06:12

user160677


1 Answers

The class is another namespace. Therefore the interface can be used to enforce contracts on data that flows between methods in the class, or just to scope the interface more precisely.

like image 81
Preet Sangha Avatar answered Dec 31 '22 12:12

Preet Sangha