is this equivalent ? (int) listofobj?.Count() to (listofobj == null)?0:listofobj.Count();

37 Views Asked by At

i have

List<someobjects> listOfObj;

i have some property where i'd like to return number of objects i tried it like

get => (int)listOfObj?.Count();

but app crashes with System.Reflection.TargetInvocationException somewhere in xamarin.forms page initializecomponent (the above said property is binded to some control )

when i change code to

get => (listOfObj==null)?0: listOfObj.Count();

all works as expected .

i think these two versions are the same , but may be i'm missing something ?

tia ish

0

There are 0 best solutions below