---
title: "How to check a string contains another string"  
description: "How to check a string contains another string"  
author: "Anonymous User"  
published: 2014-11-27  
updated: 2014-11-28  
canonical: https://www.mindstick.com/forum/12708/how-to-check-a-string-contains-another-string  
category: "asp.net"  
tags: ["c#", "string"]  
reading_time: 1 minute  

---

# How to check a string contains another string

i have [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) of numbers separated by commas ,How to [check if](https://www.mindstick.com/forum/12878/how-to-check-if-an-asp-dot-net-file-upload-control-has-a-file-in-jquery) another string contained in that string .

**For example :**

If i have a string :

67,782,452,67632,9,155,323

How to check that 155 is in the [previous](https://yourviews.mindstick.com/view/81421/unlock-2-0-is-just-like-previous-corona-lockdowns) string using [linq](https://www.mindstick.com/articles/12007/language-integrated-query-linq-queries) ?

## Replies

### Reply by Anonymous User

I assume that you want to [check](https://yourviews.mindstick.com/story/2248/never-forget-to-check-these-specifications-before-buying-a-mobile-phone) if one of the items in the string is your given string. I would split the string first by the delimiter ,, then use Contains or Any:

```
string[] items ="67,782,452,67632,9,155,323".Split(',');bool contains = items.Contains("155");contains = items.Any(i => i == "155");
```

The problem with the Contains-check on the string is that also "1550" would contain "155".


---

Original Source: https://www.mindstick.com/forum/12708/how-to-check-a-string-contains-another-string

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
