---
title: "Find in List<t> and return boolean if found"  
description: "Find in List<t> and return boolean if found"  
author: "Anonymous User"  
published: 2014-01-29  
updated: 2014-01-29  
canonical: https://www.mindstick.com/forum/1912/find-in-list-t-and-return-boolean-if-found  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Find in List<t> and return boolean if found

[public](https://www.mindstick.com/blog/11097/java-access-modifiers-the-public-and-the-private-modifiers) [class](https://www.mindstick.com/blog/165/generic-class-in-c-sharp) MyType

{

public [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) MyName;

public string MyTown;

public string MyJob;

}

I have a List of this type:

List<MyType> myVar = new List<MyType>()

[Now](https://yourviews.mindstick.com/view/81402/it-s-liberals-vs-progressives-in-us-politics-now) I want to return a [boolean](https://www.mindstick.com/forum/160332/how-does-the-boolean-function-work) based on this. So for example: Does myVar contain MyName = "Bob" and MyJob = "Taxi [Driver](https://yourviews.mindstick.com/view/80820/ola-driver-rude-behavior-with-mindstick-owners)"

I have [managed](https://www.mindstick.com/forum/33928/what-is-managed-or-unmanaged-code-in-c-sharp) to return all with a [name](https://yourviews.mindstick.com/view/87450/how-to-generate-a-brand-name-using-linkedin-comprehensive-guide) of "Bob"

[var](https://www.mindstick.com/forum/33920/what-is-different-var-and-dynamic-types-in-c-sharp) e = myVar.Where(x => x.MyName== "Bob").ToList();

But I want to do something like:

bool mExists = (myVar.Where(x => x.MyName== "Bob" && MyJob="Taxi Driver").Count > 0) ? [true](https://yourviews.mindstick.com/view/81326/boycott-chinese-products-dream-will-come-true) : false;

Is this possible?

## Replies

### Reply by Pravesh Singh

Hi Jay,

You can use .Any()

Example :

bool mExists = myVar.Any(x => x.MyName == "Steve" && x.MyJob == "Mechanic");


---

Original Source: https://www.mindstick.com/forum/1912/find-in-list-t-and-return-boolean-if-found

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
