Questions tagged [contains]

The "contains" operator/method is used to determine if an entity collection contains an element with a particular property.

The contains operator/method is used to determine whether one (or more) of the entities in an entity collection has a particular property.

3008 questions
18
votes
2 answers

JSON Schema: How to check that an array contains at least one object with a property with a given value?

How can I check in the following json that at least one element in the array names has a property nickName with the value Ginny? { "names": [ { "firstName": "Hermione", "lastName": "Granger" }, { "firstName": "Harry", …
fpenim
  • 491
  • 1
  • 4
  • 14
17
votes
3 answers

How Does List.Contains() Find Matching Items?

I have a list of car objects List cars = GetMyListOfCars(); and i want to see if a car is in the list if (cars.Contains(myCar)) { } what does Contains use to figure out if myCar is in the list. Does it do a "ToString()" on my car object. …
leora
  • 188,729
  • 360
  • 878
  • 1,366
17
votes
2 answers

Understanding contains method of Java HashSet

Newbie question about java HashSet Set s = new HashSet(); User u = new User(); u.setName("name1"); s.add(u); u.setName("name3"); System.out.println(s.contains(u)); Can someone explain why this code output false ? Moreover this code does…
user12384512
  • 3,362
  • 10
  • 61
  • 97
17
votes
5 answers

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's different between them? // Create a list of parts. List parts = new List(); // Add parts…
Vic
  • 758
  • 2
  • 15
  • 31
17
votes
4 answers

Python List Class __contains__ Method Functionality

Does the __contains__ method of a list class check whether an object itself is an element of a list, or does it check whether the list contains an element equivalent to the given parameter? Could you give me an example to demonstrate?
Jim West
  • 195
  • 1
  • 4
16
votes
7 answers

How do I find whether a string has a carriage return by using the String.Contain function using its ascii character?

In C#, how do I find whether a string has a carriage return by using the String.Contains function? The ascii for carriage return is 13. Chr(13) is how a carriage return is represented in Visual Basic. How is a carriage return represented in C#…
C N
  • 429
  • 5
  • 9
  • 15
16
votes
6 answers

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 that contain the search term. At the moment I am doing this with a plain old dataset using the Select method…
njr101
  • 9,499
  • 7
  • 39
  • 56
16
votes
3 answers

if contains certain text, then run jquery

I need to run a jquery only if the bold element contains particular text. What am I doing wrong?