0
public class Access
{
public Entity eeee { get; set; }
public Permission<eeee.GetType()> pppp { get; set; }
}
public class Entity
{
}
public class Permission<T>
{
public bool CanView {get;set;}
public bool CanEdit {get;set;}
public bool CanDelete {get;set;}
}
public class Photo:Entity
{
}
public class PhotoPermission:Permission<Photo>
{
public bool CanTag {get;set;}
}
public class Video:Entity
{
}
public class VideoPermission:Permission<Video>
{
public bool CanFastForward {get;set;}
}
所以,如果eeee
是Photo
型的,那麼的pppp
「類型」應該是Permission<Photo>
傳遞類型參數動態地泛型類型
有什麼樣eeee.GetType()
爲什麼不能只改變'public Permission pppp {get;組; }'到'public權限 pppp {get;組; ''? –