CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1

    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);
        }
    }
    Last edited by surfdabbler; May 29th, 2013 at 08:19 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured