public class MyArgs
{
int _arg1 = null;
string _arg2 = null;
public MyArgs(int arg1, string arg2)
{
_arg1 = arg1;
_arg2 = arg2;
}
public MyArgs(int arg1)
{
_arg1 = arg1;
}
public MyArgs(string arg2)
{
_arg2 = arg2;
}
public int Arg1
{
get
{
return _arg1;
}
set
{
_arg1 = value;
}
}
public int Arg2
{
get
{
return _arg2;
}
set
{
_arg21 = value;
}
}
public static MyArgs Empty
{
get
{
return null;
}
}
}
public class MyProcClass
{
public void MyProc(MyArgs args)
{
if (args == null)
{
Console.WriteLine("no args specified");
return;
}
else
{
if (args.Arg1 != null)
Console.WriteLine("optional arg1 found");
if (args.Arg2 != null)
Console.WriteLine("optional arg2 found");
}
}
public void CallMyProcExample()
{
MyProc(MyArgs.Empty);
MyProc(new MyArgs("Only arg2 defined"));
MyProc(new MyArgs(1));
MyProc(new MyArgs(1, "Both Defined"));
}
}