Silverlight / WPF - WPF-MVVM - Asked By dipak sinha on 31-Oct-11 07:21 AM

 
Dear Sir/Madam,


i am new in MVVM-WPF, In the method given below------

 public BaseCommand(Action command, Func<bool> canExecute = null)
   {
            if (command == null)
                throw new ArgumentNullException("command");
            _canExecute = canExecute;
            _command = command;
   }

there is two argument is accepted but on the colling side, it called like in this way--


 public ICommand ClickCommand 
        {
            get 
            {
                return new BaseCommand(Click); 
            }
        }


By passing only one argument instead of two,


   How its working..............
   Please help me !



dipa ahuja replied to dipak sinha on 31-Oct-11 07:27 AM
Because the second parameter of the function is optional parameter 


if you pass second parameter then it will accept it as your parameter as second parameter but if you don't pass seond parameter then it will assign the default value which is null to the optional parameter

public BaseCommand(Action command, Func<bool> canExecute null)


Jitendra Faye replied to dipak sinha on 31-Oct-11 07:34 AM
Yes, It will work, because here in declaration second parameter is optional and you have assigned it with null.

so if you will not pass any value for second parameter then null will be replaced as second parameter.

Hope this will help you.
dipak sinha replied to dipa ahuja on 31-Oct-11 07:35 AM
ok, thanks!!