Yahoo Poland Wyszukiwanie w Internecie

Search results

  1. 12 wrz 2013 · If all you need is the index, use the List<T> class's FindIndex method: int index = myList.FindIndex(s => s.Contains(myString)); This will return the the index of fist element that contains the substring myString, or -1 if no such element is found.

  2. Either use LINQ: var value = MyList.First (item => item.name == "foo").value; (This will just find the first match, of course. There are lots of options around this.) Or use Find instead of FindIndex: var value = MyList.Find (item => item.name == "foo").value; I'd strongly suggest using LINQ though - it's a much more idiomatic approach these days.

  3. Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the range of elements in the List<T> that starts at the specified index and contains the specified number of elements. FindIndex(Predicate<T>)

  4. Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the List<T> that starts at the specified index and contains the specified number of elements. public: int IndexOf (T item, int index, int count);

  5. 27 sty 2023 · public int ArrayFindIndexWithContains() { string value = "du"; int index = Array.FindIndex(_stringArray, str => str.Contains(value)); return index; } This method returns the index of the first string that contains the value du.

  6. 5 gru 2021 · The recommended solution is to use the List<T>.FindIndex() method that returns the index of the first occurrence of the specified element that matches the conditions defined by a specified predicate. This method returns -1 if an item that matches the conditions is not found.

  7. Contains (T) Examples. The following example demonstrates the Contains and Exists methods on a List<T> that contains a simple business object that implements Equals. using System; using System.Collections.Generic; // Simple business object.

  1. Ludzie szukają również