IList<Person> GetPersons() => someList.Where(t => t != null).ToList()!; // or IList<Person> GetPersons() => (IList<Person>)someList.Where(t => t != null).ToList();