Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to compare nullable int with list<int>?

var selectId = array.Where(x => x.Id != null);

selectId.Where(x => x.Id == settings.PersonIds);

Id is a nullable int and settings.PersonIds is a list of int.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

How do i compare and check if the id is the same as settings.PersonIds?

Edit* i am trying to see if the list of int (settings.PersonIds) contains the int (Id)

>Solution :

Use Contains

array.Where(x => x.Id.HasValue && settings.PersonIds.Contains(x.Id.Value));
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading