c# - Cannot use Enumerable.Count with List, compiler assumes List.Count -



c# - Cannot use Enumerable.Count with List, compiler assumes List.Count -

i haven't noticed behaviour yet, maybe because prefer query syntax in vb.net , split query , execution-methods different statements.

if seek compile next simple query:

dim wordlist list(of string) = new list(of string) dim longwords int32 = wordlist.count(function(word) word.length > 100)

the compiler doesn't because expects no arguments list.count:

"public readonly property count integer" has no parameters , homecoming type cannot indexed.

if declare ienumerable(of string) works expected:

dim wordseq ienumerable(of string) = new list(of string) dim longwords int32 = wordseq.count(function(word) word.length > 100)

why so? prevents compiler using enumerable extension method count instead of icollection.count property. note i've added imports system.linq , both option strict , option infer on. i'm using.net 4.0 (visual studio 2010).

i'm confused because in c# works without problem:

list<string> wordlist = new list<string>(); int longwordcount = wordlist.count(word => word.length > 100);

it's by design, quote msdn:

the situation simpler properties: if extension method has same name property of class extends, extension method not visible , cannot accessed.

c# .net vb.net linq

Comments

Popular posts from this blog

php - Edges appear in image after resizing -

ios8 - iOS custom keyboard - preserve state between appearances -

Delphi change the assembly code of a running process -