Forgive my ignorance if this is ‘a basic question’…..
I have a method that needs to be able to accept differing numbers and types of inputs. Eg
protected void example(int iVar, string sVar)
&/or
protected voide example(int iVar, string sVar, double dVar)
Putting aside questions/comments such as “Why????”, is there an easy / shorthand way of doing this without writing the method twice?
Any help &/or pointers will be very greatfully received.
Thanks in advance.
You can make your last parameter an optional argument (C# 4.0 and above):
Alternatively, the implementation of the first method could simply call the second: