Click here to Skip to main content
15,909,091 members
Home / Discussions / C#
   

C#

 
GeneralRe: passing a struct Pin
VanEtienne5-Feb-06 20:02
VanEtienne5-Feb-06 20:02 
GeneralRe: passing a struct Pin
rakesh_nits5-Feb-06 21:32
rakesh_nits5-Feb-06 21:32 
GeneralRe: passing a struct Pin
VanEtienne5-Feb-06 21:45
VanEtienne5-Feb-06 21:45 
AnswerRe: passing a struct Pin
Guffa5-Feb-06 23:46
Guffa5-Feb-06 23:46 
GeneralRe: passing a struct Pin
virz5-Feb-06 22:54
virz5-Feb-06 22:54 
GeneralRe: passing a struct Pin
ryancrawcour5-Feb-06 21:45
ryancrawcour5-Feb-06 21:45 
Questiondid someone forget typedef? Pin
User 5838525-Feb-06 18:32
User 5838525-Feb-06 18:32 
AnswerRe: did someone forget typedef? Pin
leppie5-Feb-06 19:30
leppie5-Feb-06 19:30 
AnswerRe: did someone forget typedef? Pin
leppie5-Feb-06 19:37
leppie5-Feb-06 19:37 
GeneralRe: did someone forget typedef? Pin
User 5838525-Feb-06 22:02
User 5838525-Feb-06 22:02 
Questionsuggestion about any Code generator Wizard Pin
emran8345-Feb-06 17:18
emran8345-Feb-06 17:18 
AnswerRe: suggestion about any Code generator Wizard Pin
leppie5-Feb-06 20:50
leppie5-Feb-06 20:50 
GeneralRe: suggestion about any Code generator Wizard Pin
emran8345-Feb-06 22:20
emran8345-Feb-06 22:20 
GeneralRe: suggestion about any Code generator Wizard Pin
leppie6-Feb-06 0:47
leppie6-Feb-06 0:47 
QuestionC# visual studio error? Pin
paully5-Feb-06 17:14
paully5-Feb-06 17:14 
AnswerRe: C# visual studio error? Pin
emran8345-Feb-06 17:20
emran8345-Feb-06 17:20 
QuestionDefault parameter in Method Pin
emran8345-Feb-06 17:10
emran8345-Feb-06 17:10 
AnswerRe: Default parameter in Method Pin
S. Senthil Kumar5-Feb-06 18:13
S. Senthil Kumar5-Feb-06 18:13 
GeneralRe: Default parameter in Method Pin
emran8345-Feb-06 22:15
emran8345-Feb-06 22:15 
AnswerRe: Default parameter in Method Pin
ryancrawcour5-Feb-06 21:49
ryancrawcour5-Feb-06 21:49 
you could do something like the following;

class ParameterClass
{
public string Name;
public int IDNumber;

public ParameterClass()
{
//set some default values;
//since both fields are public they can
//be overridden if necessary
this.Name = "";
this.IDNumber = 0;
}
}
class OptionalParameters
{
[STAThread]
static void Main(string[] args)
{

//instantiate a parameter class object
//and override the name field
ParameterClass c = new ParameterClass();
c.Name = "Lamont Adams";
optionalObject(c);

//show that the changed ID came back
Console.WriteLine("c.IDNumber={0}",c.IDNumber);

//call the method with only defaults
optionalObject(new ParameterClass());

//pause so we can see the output
Console.ReadLine();
}
public static void optionalObject(ParameterClass arg)
{
//because the parameters received are encapsulated
//in an object, they are all optional but have
//a valid state even if not explicitly set by the caller
Console.WriteLine("arg.Name={0}, arg.IDNumber={1}", arg.Name, arg.IDNumber);

//change one of the field values
arg.IDNumber = 10;
}
}


this way you don't have to have an overload for every single combination of parameters.
hope this helps...
GeneralRe: Default parameter in Method Pin
emran8345-Feb-06 22:19
emran8345-Feb-06 22:19 
GeneralRe: Default parameter in Method Pin
ryancrawcour5-Feb-06 22:23
ryancrawcour5-Feb-06 22:23 
QuestionRestore DataBase Using SQLDMO Pin
chudapji5-Feb-06 16:55
chudapji5-Feb-06 16:55 
QuestionWindow Form frozen after calling method Show() Pin
bc11185-Feb-06 16:34
bc11185-Feb-06 16:34 
AnswerRe: Window Form frozen after calling method Show() Pin
Christian Graus5-Feb-06 16:42
protectorChristian Graus5-Feb-06 16:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.