문제

I'm trying to search a list and see if an ID is in it.

            string idText = item["FCSID"].Text;
            var sfhOptions = PathologySFHByRole.GetSFHOptionsByRoles(Model.pathologyFishCultureStation);
            if (!sfhOptions.Contains(x => x.ID == int.Parse(idText))) 
                e.Item.Cells[0].Visible = false;

The GetSFHOptionsByRoles returns an IList. My lambda expression gets the error: Cannot convert the lambda expression to type SFHType because it is not a delegate type

What's the best practice for this?

도움이 되었습니까?

해결책

You can use Any:

int id = int.Parse(idText);
e.Item.Cells[0].Visible = sfhOptions.Any(x => x.ID == id);

IList<T>.Contains expects an object of type SFHType instead of a predicate.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top