The difference between contains and contains <> in C #

I may be stupid, but what is the difference between containsand contains<>in helping VS? Sometimes I get both, sometimes only one with <>.

All that I am trying to use is that, as with some of the solutions found here in SO, but this raises an error that has a better overload method, has some invalid arguments (their method System.Linq.ParallelEnumerable.Contains<TSource>(...)).

My code looks like this:

defaultDL = db.SomeEntity
                    .Where(dl => dl.Something == this.Something
                        && (dl.AllLocation == true || this.SomeOtherEntity.Select(loc => loc.Location).Contains(dl.Location)))
                    .ToList();
+4
source share
4 answers

If you move on to defining a method System.Linq.Enumerable.Contains, you will see that it is declared as a general extension method.

public static bool Contains<TSource>(this IEnumerable<TSource> source, TSource value);

, <type>, , - , . .

someCollection.Contains(someValue);

Enumerable.Contains<CollectionInnerType>(someCollection, someValue);
+4

Linq Contains<>. , . - # .

(, List<>) Contain.

, IntelliSense Contains<> - Linq; Contains - .

. , Linq, Linq .

+1

. .

, SomeOtherEntity ICollection<T>. ICollection, ( ). .

Contains<T>, LINQ. . IEnumerable<T>, ICollection<T>. .

0

.

  • , Contains - .
  • retrun IEnumerable<T>, Contais bool , . Contain deligates, IEnumerable<T>.
0

Source: https://habr.com/ru/post/1625303/


All Articles