简体   繁体   中英

System.Linq without Array.Contains

I included in Global.asax the following:

<%@ Import Namespace="System.Linq" %>
.
.
.
<script runat="server">
   MyLib.ReturnArray().Contains(<value>);
</script>

Still, I received the infamous System.Array does not contain a definition for 'Contains'...

Why wouldn't it work?

PS

Might be connected to this (unanswered) question . Maybe details there could help answer this one.

Contains expects an element you're looking for, not a lambda. Use Any to check if there is at least one element matching a predicate.

Contains Determines whether the specified object exists as an element

The Contains method accepts a single parameter: the searched-for element. The LINQ Contains method accepts two parameters, with an additional IEqualityComparer instance that specifies how elements are compared for equality.

MSDN REF link , Ref2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM