Kind of stumped with some basic C# constructors.

Posted by Sergio Tapia on Stack Overflow See other posts from Stack Overflow or by Sergio Tapia
Published on 2010-06-12T03:04:10Z Indexed on 2010/06/12 3:12 UTC
Read the original article Hit count: 315

Filed under:
|
|
public class Parser
{
    Downloader download = new Downloader();
    HtmlDocument Page;

    public Parser(string MovieTitle)
    {
        Page = download.FindMovie(MovieTitle);
    }

    public Parser(string ActorName)
    {
        Page = download.FindActor(ActorName);
    }
}

I want to create a constructor that will allow other developers who use this library to easily create a Parser object with the relevant HtmlDocument already loaded as soon as it's done creating it.

The problem lies in that a constructor cannot exist twice with the same type of parameters. Sure I can tell the logical difference between the two paramters, but the computer can't.

Any suggestions on how to handle this?

Thank you!

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET