How do we implement private interfaces

A) Using Inherits Keyword
B) Using Implements Keyword
C) Private interfaces can not be implemented
Explanation: Interfaces must always be declared as public so that they can be implemented or inherited

Showing Answers 1 - 8 of 8 Answers

ravi

  • Mar 10th, 2006
 

yes there is no private interfaces

  Was this answer useful?  Yes

sonj

  • Apr 20th, 2006
 

Interface should be in public so private is wrong

  Was this answer useful?  Yes

Deepak

  • May 28th, 2014
 

B

  Was this answer useful?  Yes

Pravesh Rai

  • Aug 25th, 2016
 

Answer is yes. we can implements private interface but within the class. See the example below

Code
  1. public class MyClass

  2. {

  3.     private interface IFoo

  4.     {

  5.         int MyProp { get; }

  6.     }

  7.  

  8.     private class Foo : IFoo

  9.     {

  10.         public int MyProp { get; set; }

  11.     }

  12.  

  13.     public static void Main(string[] args)

  14.     {

  15.         IFoo foo = new Foo();

  16.         return foo.MyProp;

  17.     }

  18. }

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions