How to tell Resharper that a List/Enumerable will not contain null elements

Hi

I ues something like that

var family = System.Drawing.FontFamily.Families.Where(ff => ff.Name == FontFamily).FirstOrDefault();


and R# warns me that ff is perhaps null so I have to add a null check

var family = System.Drawing.FontFamily.Families.FirstOrDefault(ff => ff != null && ff.Name == FontFamily);


Same problem here

foreach(var aString in myStrings.Where(s=>!string.IsNullOrEmpty(s)) {
    if(s.Contains("a")...


I checked before that aString is not null but still get a warning here.

Is there some possibility already to tell R# in some way that I already maked sure that there is no null in the list?

Kind reagrds,
Sven

0

Please sign in to leave a comment.