troubleshooting Question

An if statement inside a list ?

Avatar of lulu50
lulu50Flag for United States of America asked on
8 Comments1 Solution139 ViewsLast Modified:
Hello everyone,

I need your help please.

How can I have an if statement inside my list
I want to say if the selectedFilterList contain "status" then display the status field on my grid.

I have a dropdown list for the user to select a specific fields to display in my grid.

 modelList = list.ToList().Select(x => new RuleDetail

                if (model.SelectedFilterList.Contains("Status"))  // I need to do the same to all of them if SelectedFilterList contain the string then display it
                {                                                                                 //I have an error here 
                    Status = (Boolean)x.isActive,                            // Can I do an if inside a list? 

                //Status = (Boolean)x.isActive,
                RuleSet = GetRuleset.Where(a => a.RuleSetId == x.RuleSetId).FirstOrDefault().RuleSet,
                RuleIdentifier = GetRuleIdentifier.Where(a => a.RuleIdentifierId == x.RuleIdentifierId).FirstOrDefault().RuleIdentifier,
                Versions = x.Version,
                Environments = x.Environment,
                CommitID = x.CommitID,
                CommitDescription = x.CommitDescription,
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros