Is there a way to hide/show a method if a certain constructor is used? i.e.:
public class SomeClass
{
public SomeClass(string methodA)
{
}
public SomeClass(int methodB)
{
}
public string MethodA()
{
return "";
}
public int MethodB()
{
return 0;
}
}
if SomeClass(string methodA) is used, then only MethodA() is available when I instance a new SomeClass object? The same when SomeClass(int methodB) is used, then MethodB() would be available?
Thank you all!
No, it’s not possible.
What’s more likely is that you want to use generics:
If you don’t need to restrict it to just strings or ints (or don’t want to) then something like this might work, or even be better: