>Am I missing something? If Test was defined with 3 arguments, all three are required. If the constructor is only set up for 3, you couldn't:
Yes you're missing the params keyword which allows for a variable argument list. Look it up. Params gives you an array of object and you can pass any number of parameters as simple parameters.
public Test(params object[] args) { }
+++ Rick ---
>>>As you know, that's not really what I had in mind :o) but yes, that does work.
>>
>>No I don't know what you mean. How is this different that what you can do in VFP:
>>
>>
>>Test test = new Test('Hello',1,DateTime.Now);
>>
>>
>>Same thing - you get a list of untyped vars in the constructor.
>>
>>+++ Rick ---
>
>Am I missing something? If Test was defined with 3 arguments, all three are required. If the constructor is only set up for 3, you couldn't:
>
>Test test = new Test('Hello',1);
>
>I'd have to code a constructor for 0, 1, 2, and 3 arguments passed if I wanted any of them to be optional. I couldn't pass 2 and have the constructor run with only 2 passed and create a default value for the 3rd argument not passed (like vfp does) - it won't even compile. That's what I meant. You have to code for every possibility. You have to overload the constructor:
>
>
> public class Test
> {
> public Test()
> {
> // This is the no parameter constructor method.
> }
>
> public Test(string Mesg)
> {
> // This is the constructor with one parameter.
>
> }
>
> public Test(string Mesg, int Age)
> {
> // This is the constructor with two parameters.
> }
>
> // rest of the class members
> }
>
>
>in order to pass 0, 1, or 2 arguments. By optional, I meant: If I want to pass the 3rd argument, I have to create another constructor that handles 3 arguments. I can't put it all in one like in VFP:
>
>
>llReturnVal = Test('Hello',1,DateTime.Now)
>
>FUNCTION Test
>LPARAMETERS qcMesg, qiAge, qdDateTime, qlFourthParam
>
>*If qlFourthParam is not passed, it is .F.
>*Any params not passed are .F.
>
>*function code here
>
>RETURN llReturnValue
>
>
>That's what I meant by 'optional' parameters in one class like you can do in VFP.
>
>(Sorry for all the typos :o)