Syntax help in C#

B_Pati
B_Pati used Ask the Experts™
on
Hi,

Can some one help me with the explanation on this Syntax.

 _openProjectCommand
                    ?? (_openProjectCommand = new RelayCommand(() => { OpenProject(); }));
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Kyle AbrahamsSenior .Net Developer
Commented:
http://msdn.microsoft.com/en-us/library/ms173224.aspx

Use open ProjectCommand or if it's null set OpenProjectCommand to a new RelayCommand which points to output of OPenProject();
Top Expert 2011
Commented:
?? is the null-coalescing operator.

 _openProjectCommand
                    ?? (_openProjectCommand = new RelayCommand(() => { OpenProject(); }));

Is equivalent to:
if (_openProjectCommand == null)
{
    _openProjectCommand = new RelayCommand(() => { OpenProject(); });
}

Open in new window


?? Operator (C# Reference)
http://msdn.microsoft.com/en-us/library/ms173224.aspx

Btw, I think this is a misuse of the ?? Operator, as it makes the code harder to understand.

Author

Commented:
Thanks for the help i will look into the links .

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial