I am very new to C#, but have to use it for a project at work, so I apologize if this is a duplicate, use the wrong vocabulary or am asking a simple question (it is hard to research a question when you don't understand what the question should be).
I have a class with multiple constructors. I want the properties of that class to be based on the constructor that I call. This is the code I have now:
public class MyClass
{
public object Property1;
public object Property2;
public object Property3;
public MyClass(object newProperty1, object newProperty2, object newProperty3)
{
Property1 = newProperty1;
Property2 = newProperty2;
Property3 = newProperty3;
}
public MyClass(object newProperty1, object newProperty2)
{
Property1 = newProperty1;
Property2 = newProperty2;
}
}
What happens is when I call the second constructor is I get an empty Property3 object. What I want to have happen is that there is no Property3 object property included in MyClass at all when the second constructor is called.
Is this possible? Thanks in advance for the help.
public object Property1 {get; set;}