I am trying to call a method that requires some parameters based on previous parameters chosen.
This is probably better explained with an example:
public static void MyMethod (string p1, string p2, string p3 = "", string p4 = "")
{
}
What I want to achieve is requiring p4 if p3 is given.
If I were to call it like this:
MyMethod("Hello", "World", "P3", // p4 now required as p3 given a value)
I hope this makes sense. Thanks.
Instead of default values for parameters (which has its own problems), I would use overloading: