Constructor overload contains already defines a member with the same signature

后端 未结 3 1933
温柔的废话
温柔的废话 2021-01-28 05:48
public Module(string a, object obj) : this(a, null, obj) { }

public Module(string b, object obj) : this(null, b, obj) { }

These constructor overloads

3条回答
  •  忘掉有多难
    2021-01-28 06:31

    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); }
    

提交回复
热议问题