.net - C# constructors with same parameter signatures -


I'm sure this will be a common problem. I have got a class that will be the following constructor in a perfect world

  public talk (string connection string) public talk (string filename)  

obviously This is not allowed because signatures are the same. Does anyone know an elegant solution to this problem?

You can use named constructor phrases:

  public Talk of class {private string connection string; Private string filename; Private talk () {/ * Make it private to clear this thing} / / Public stable Thing with connection (string connection string) {var thing = new thing (); Thing.connectionString = connectionString; Talk of return; } Public Fixed Thing with Female Name (string filename) {var thing = new Thing (); Thing.filename = filename; Talk of return; }}  

Comments