Hi I’m unable to create a new object that is a subclass I think that’s what you call it it saying virtual isn’t allowed what must I do to correct this here is my code.
public class PagerBuilder {
private virtual class PagerLink
{
public string Title { get; set;}
public int PageNo { get; set; }
public string Class { get;set;}
}
private readonly List<PagerLink> _pagerLinks = new List<PagerLink>();
private readonly string _urlTemplate;
public PagerBuilder(string urlTemplate)
{
_urlTemplate = urlTemplate;
}
public string PagerClass { get;set;}
public void AddPage(string title, int pageNo)
{
AddPage(title, pageNo, string.Empty);
}
public void AddPage(string title, int pageNo, string itemClass)
{
PagerLink link = new PagerLink();
}
}
First, I would move
PagerLinkoutside of thePagerBuilderclass and define it separately (in a new file as well).Second, you don’t need virtual to subclass
PagerLink(It’s not even valid, in fact). If you want it to be abstract, use theabstractkeyword instead, but this code won’t compile (atPagerLink link = new PagerLink()until you define a concrete implementation ofPagerLink. You don’t need to useabstractto inherit fromPagerLink, though. Just do this: