![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Professional Programmer
Join Date: Mar 2005
Posts: 343
Rep Power: 4
![]() |
A standards question, optional inputs into Methods
I'm creating a few methods that have a number of optional inputs
Quick example, say you have a method that prints Hello <name> where <name> is optional input parameter (I know, it's a ridiculously simple example, but bare with me) so you have two options I can do
public void PrintHi()
{
code
}
public void PrintHi(string name)
{
code
}which would work fine, but when you have say 10 optional variables and you can have any combinations of them it's quite a lot of different methods (plus you start running into issues if all your variables are of the same type). However the other way, just having one method with the variables all in, but allowing null/0/? inputs for the optional portions seems somewhat clumsy, anyone have other ideas? or other ways this "should" be done? |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|