Prev: First deployment of .net winforms help needed
Next: How to Handle Nulls Passed to Extension Methods
From: Harlan Messinger on 10 May 2010 19:03 Arne Vajh�j wrote: > On 10-05-2010 18:16, AMP wrote: >> On May 10, 5:55 pm, Arne Vajh�j<a...(a)vajhoej.dk> wrote: >>> On 10-05-2010 17:53, AMP wrote: >>> >>>> This looks like an interface as a field or property: >>>> public class AccountController : Controller >>>> { >>> >>>> public IFormsAuthenticationService FormsService { get; set; } >>>> public IMembershipService MembershipService { get; set; } >>> >>>> protected override void Initialize(RequestContext >>>> requestContext)................ >>> >>>> What am I missing? >>> >>> A question maybe? >>> >>> :-) >>> >>> There is nothing wrong by having a property of a type that >>> is an interface. >> >> Thanks Arne, but where can I find some MSDN documentation for this, I >> havent seen it before? > > The docs say that it can be of a type. An interface is a type. Most > likely noone considered it necessary to say that type includes > interfaces. Following up on what Arne said, the point is that the method invoking one of these property expects to receive an object of some class that implements the interface. It doesn't need to know what the class is--it only needs to know that it can call the class's implementation of the interface's methods and properties and so on. Likewise, a method that sets the property can set it to an object of any class that implements the interface--it doesn't matter which one.
First
|
Prev
|
Pages: 1 2 Prev: First deployment of .net winforms help needed Next: How to Handle Nulls Passed to Extension Methods |