c# - What is a private interface? -
Some time ago in an interview. For the net position the interviewer asked me "Will you use a personal interface?" .
I asked him if there is a difference between indirect versus clear interface implementation, for which he did not answer.
So I'm thinking:
- What does that mean?
- For whom would you use a personal interface?
An interface can be private within another class
Public Class MyClass {Personal Interface IFoo {int MyProp {get; }} Private class Foo: IFoo {public int MyProp {get; Set; }} Public static zero main (string [] args) {IFoo foo = new Foo (); Return foo.MyProp; }}
In the case of utility it hides from other codes, even in the same assembly, it has been said that the interface is present.
There is a different thing, there are some very useful cases (especially when dealing with generic and old non-generic interfaces) but I do not say it 'private interface' and do not say that the word is usually in that way is used to.
Using two technologies at once, you can:
Public class MyClass {Personal Interface IFoo {int MyProp {get; }} Public Category Foo: IFoo {int IFoo.MyProp {get; Set; }} Public static zero main (string [] args) {IFoo foo = new Foo (); Return foo.MyProp; }} Public Square HiddenFromMe {Public Stable Zero Main (string [] args) {MyClass.Foo foo = new MyClass.Foo (); Return foo.MyProp; // fails to compile}} This allows you to expose nested classes in some crops, while the parents allow the class to implement those methods. The external world can not do that. This is a potentially useful case, but there is nothing that I want to use many times. Surely it is used in an interview using an interviewer, because they have seen it and although it was 'interesting'
Comments
Post a Comment