Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Apr 26th, 2005, 12:14 PM   #1
Arla
Professional Programmer
 
Arla's Avatar
 
Join Date: Mar 2005
Posts: 343
Rep Power: 4 Arla is on a distinguished road
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?
Arla is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:43 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC