Passing derived class members to base class constructer?
I'm trying to derive a class from HtmlTextWriter to specifically write Html to a string.
This means constructing the HtmlTextWriter class with some strings, but as these strings are part of the derived class, I can't pass them to the base class constuctor! Here's my code. Any ideas to get around this?
Of course I can simply have an instance of HtmlTextWriter within the base class, but then I can't just call all the members of HtmlTextWriter directly in my HtmlStringWriter class. :(
Code:
public class HtmlStringWriter : HtmlTextWriter
{
StringBuilder htmlString;
StringWriter stringWriter;
//
public HtmlStringWriter()
{
htmlString = new StringBuilder(); // this will hold the string
stringWriter = new StringWriter(htmlString);
base(stringWriter);
}
}