Say I have the following interface for exposing a paged list
public interface IPagedList
{
IEnumerable PageResults { get; }
int Current
My approach here would be to use new
to re-declare the PageResults
, and expose the T
as a Type
:
public interface IPagedList
{
int CurrentPageIndex { get; }
int TotalRecordCount { get; }
int TotalPageCount { get; }
int PageSize { get; }
Type ElementType { get; }
IEnumerable PageResults { get; }
}
public interface IPagedList : IPagedList
{
new IEnumerable PageResults { get; }
}
This will, however, require "explicit interface implementation", i.e.
class Foo : IPagedList
{
/* skipped : IPagedList implementation */
IEnumerable IPagedList.PageResults {
get { return this.PageResults; } // re-use generic version
}
Type IPagedList.ElementType {
get { return typeof(Bar); }
}
}
This approach makes the API fully usable via both the generic and non-generic API.