tagged [contains]

Get only Whole Words from a .Contains() statement

Get only Whole Words from a .Contains() statement I've used .Contains() to find if a sentence contains a specific word however I found something weird: I wanted to find if the word "hi" was present in...

20 Jun at 09:12

String contains another two strings

String contains another two strings Is it possible to have the contain function find if the string contains 2 words or more? This is what I'm trying to do: When I run this, the console window just

18 Dec at 19:33

Case insensitive comparison in Contains under nUnit

Case insensitive comparison in Contains under nUnit I'm trying to assert that a list contains a certain string. Since I'd need the condition to be evaluated case insensitively, I used a workaround (so...

8 Jul at 14:20

how to check if List<T> element contains an item with a Particular Property Value

how to check if List element contains an item with a Particular Property Value ``` public class PricePublicModel { public PricePublicModel() { } public int PriceGroupID { get; set; } public doub...

8 Feb at 20:6

How do I use LINQ Contains(string[]) instead of Contains(string)

How do I use LINQ Contains(string[]) instead of Contains(string) I got one big question. I got a linq query to put it simply looks like this: The values of the `string[]` array would be numbers like (...

2 Dec at 18:46

Comparing object used as Key in Dictionary

Comparing object used as Key in Dictionary my class: and main example: ``` Dictionary> dict = new Dictionary>(); myClass first = new myClass(); first.A = 2; first.B = 3; myClass second = new m

Pandas: Check if row exists with certain values

Pandas: Check if row exists with certain values I have a two dimensional (or more) pandas DataFrame like this: Now suppose I have a numpy array like `np.array([2,3])` and want to check if there is any...

15 Jul at 14:53

How to use Linq to check if a list of strings contains any string in a list

How to use Linq to check if a list of strings contains any string in a list I'm constructing a linq query that will check is a string in the DB contains any of the strings in a list of strings. Someth...

1 Nov at 16:39

Check if an ArrayList contains every element from another ArrayList

Check if an ArrayList contains every element from another ArrayList There is probably a simple one-liner that I am just not finding here, but this is my question: How do I check if an ArrayList contai...

18 Oct at 21:35

What does Collection.Contains() use to check for existing objects?

What does Collection.Contains() use to check for existing objects? I have a strongly typed list of custom objects, `MyObject`, which has a property `Id`, along with some other properties. Let's say th...

20 Dec at 22:30

High performance "contains" search in list of strings in C#

High performance "contains" search in list of strings in C# I have a list of approx. 500,000 strings, each approx. 100 characters long. Given a search term, I want to identify all strings in the list ...

29 Sep at 16:16

Check if element is in the list (contains)

Check if element is in the list (contains) I've got a list of elements, say, integers and I want to check if my variable (another integer) is one of the elements from the list. In python I'd do: How t...

24 Dec at 07:56

IEnumerable<T>.Contains with predicate

IEnumerable.Contains with predicate I need just to clarify that given collection contains an element. I can do that via `collection.Count(foo => foo.Bar == "Bar") > 0)` but it will do the unnecessary ...

C# Time complexity of Array[T].Contains(T item) vs HashSet<T>.Contains(T item)

C# Time complexity of Array[T].Contains(T item) vs HashSet.Contains(T item) `HashSet(T).Contains(T)` (inherited from [ICollection.Contains(T)](https://learn.microsoft.com/en-us/dotnet/api/system.colle...

.Contains() on a list of custom class objects

.Contains() on a list of custom class objects I'm trying to use the `.Contains()` function on a list of custom objects. This is the list: And the `CartProduct`: ``` public class CartProduct { public...

2 Jun at 19:50

Entity Framework: Precompiled Query for Enumerable.Contains

Entity Framework: Precompiled Query for Enumerable.Contains Entity Framework 5+ is supposed to precompile all queries. However, for queries such as Entity Framework cannot precompile the query, and de...

Using Linq to do a Contains with multiple values

Using Linq to do a Contains with multiple values I have a medication table that I'm looking for certain drug names, but I need to search for multiple names. Here is where I currently am with it. ``` s...

6 Mar at 22:24

What's different between Contains and Exists in List<T>?

What's different between Contains and Exists in List? I want to know what's different between `Contains` and `Exists` in `List` ? They can both determine whether an element is in the `List`. But what'...

31 Jul at 08:22

In C#, best way to check if stringbuilder contains a substring

In C#, best way to check if stringbuilder contains a substring I have an existing `StringBuilder` object, the code appends some values and a delimiter to it. I want to modify the code to add the logic...

3 Dec at 20:55

Using contains() in LINQ to SQL

Using contains() in LINQ to SQL I'm trying to implement a very basic keyword search in an application using linq-to-sql. My search terms are in an array of strings, each array item being one word, and...

Case insensitive 'Contains(string)'

Case insensitive 'Contains(string)' Is there a way to make the following return true? There doesn't seem to be an overload that allows me to set the case sensitivity. Currently I UPPERCASE them both, ...

28 Jan at 12:44

Check if list contains element that contains a string and get that element

Check if list contains element that contains a string and get that element While searching for an answer to this question, I've run into similar ones utilizing LINQ but I haven't been able to fully un...

12 Sep at 14:45

FileUpload.FileName behavior when there is a semi-colon or opening bracket in the file name

FileUpload.FileName behavior when there is a semi-colon or opening bracket in the file name I have a FileUpload control, and there are certain restrictions on the file name, certain characters that sh...

10 Sep at 02:47

List<T>.Contains and T[].Contains behaving differently

List.Contains and T[].Contains behaving differently Say I have this class: ``` public class Animal : IEquatable { public string Name { get; set; } public bool Equals(Animal other) { return N...

23 May at 11:57

c# contains part of string

c# contains part of string So I have a list with Materiel-objects. In Materiel I have 15 get and set methods. I want to construct a search-method that loops all the objects in the list, and all of the...

29 Mar at 10:17