1
    public class WorkingList
    {
        public string Name { get; set; }

        public bool Working { get; set; }
    }

Class WorkingList is Contains String

i want use like

       public List<WorkingList> Work = new List<WorkingList>(); 
       bool ContainsCheck=false;
       foreach(WorkingList list in Work)
       {
          if(list.Name.Equals("FindName")) { ContainsCheck = true; break }
       }

I Want Know Easy get List contains String Method!

using linq ? or anymethod / and

          public class TopClass
          {
             public List<WorkingList> Work = new List<WorkingList>(); 
             public string TopName { get; set; }
          }

i want know easy way Topclass.Work.Name contains string result

2 Answers 2

2
bool ContainsCheck = Work.Any(list => list.Name.Equals("FindName"));
Sign up to request clarification or add additional context in comments.

Comments

0

You can use this:

  ContainsCheck =work.any(i=>i.Name=="FindName");

1 Comment

To up the educational value of your answer, perhaps provide some minimal description on what the code does or why it is a solution. Not everyone might be experienced enough to understand.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.