How am I misusing the null-coalescing operator? Is this evaluating “null” correctly?

This is Unity screwing with you. If you do this: MeshFilter GetMeshFilter() { MeshFilter temp = myGo.GetComponent<MeshFilter>(); if ( temp == null ) { Debug.Log( ” > Get Mesh Filter RETURNING NULL” ); return null; } return temp; } It works. Why? Because Unity has overridden Equals (and the == operator) on all Unity objects … Read more

An expression tree lambda may not contain a null propagating operator

The example you were quoting from uses LINQ to Objects, where the implicit lambda expressions in the query are converted into delegates… whereas you’re using EF or similar, with IQueryable<T> queryies, where the lambda expressions are converted into expression trees. Expression trees don’t support the null conditional operator (or tuples). Just do it the old … Read more

What do two question marks together mean in C#?

It’s the null coalescing operator, and quite like the ternary (immediate-if) operator. See also ?? Operator – MSDN. FormsAuth = formsAuth ?? new FormsAuthenticationWrapper(); expands to: FormsAuth = formsAuth != null ? formsAuth : new FormsAuthenticationWrapper(); which further expands to: if(formsAuth != null) FormsAuth = formsAuth; else FormsAuth = new FormsAuthenticationWrapper(); In English, it means … Read more