public Module(string a, object obj) : this(a, null, obj) { }
public Module(string b, object obj) : this(null, b, obj) { }
These constructor overloads
Parameter names are meaningless in the context of overloads. I can see what you are trying to do, but I'm not sure why. I would dispense with it entirely:
public Module(string a, string b, object obj){}
Then call the Module
constructor, passing in null
values as appropriate.
Module m = new Module(null, "hi", obj);
Module m2 = new Module("bye", null, obj);
personally i use optional arguments:
public Module(object obj, string a = null,string b = null) : this(a, b, obj) { }
Heres an article on what they are and how to use them, Note though they are only avaliable in VS2010 (they are part of the compiler not the language so they are available in .net 3.5 as well as 4.0) http://msdn.microsoft.com/en-us/library/dd264739.aspx
It's just not possible. You should remove those two constructor overloads.
However, you could work with static factory methods instead. Make sure to use clear names to convey the difference to the API consumer.
static Module CreateA(string a, object o) { return new Module(a, null, o); }
static Module CreateB(string b, object o) { return new Module(null, b, o); }