c# - ICollection in interface with another interface as the type -


Is it possible to designate the interface as the type of general storage property of a different interface, and then after that it has a specific class ? Here's an example of what I'm trying to do:

  Public Interface IMembershipPrincipal {int ID {get; Set; } String Username {get; Set; } ICollection & lt; IEmail & gt; get an email; Set; }} Public Interface IEmail {String Address {get; Set; } Int UserID {get; Set; }}  

And define the actual classes in any other project:

  public class users: IMembershipPrincipal {[Key] public int id {get; Set; } Public String Username {get; Set; } Public virtual iconging & lt; Email & gt; get an email; Set; }} Public Class Email: IEML {{Key} Public String Address {get; Set; } Public int UserID {get; Set; }}  

The IMembershipPrincipal has access to the only IEML definition, but I want to apply the IECL using the email rather than IECL. I am currently receiving an error which says:

Error 1 'User' does not apply to 'Interface Member' IMembershipPrincipal.Emails 'User.Emails' 'IMembershipPrincipal.Emails' Can not apply because it contains' system.clalls. Generic Collisions' is not a return type.

How can I change my IMembershipPrincipal is to define it as the ICollection & lt; Email & gt;

Can be implemented with just being clear, I understand that the virtual archive is ICollection & lt; IEmail & gt; Code must be created, but this unit destroys my path in the path structure so that I can MyUser.Emails.Where (...) .

As mentioned by others, sympathy lets you use code from your example Prevents from You can, however, use common types and obstacles to achieve the desired effect.

Public Interface IMembershipPrincipal & lt; T & gt; Where T: IEmail {int ID {receives; Set; } String Username {get; Set; } ICollection & lt; T & gt; get an email; Set; }} Public Interface IEmail {String Address {get; Set; } Int UserID {get; Set; }} Public Squared User: IMembershipPrincipal & lt; Email & gt; {[Key] Public ID {Receive; Set; } Public String Username {get; Set; } Public virtual iconging & lt; Email & gt; get an email; Set; }} Public Class Email: IEML {{Key} Public String Address {get; Set; } Public int UserID {get; Set; }}

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -