未找到类型'String()'上的公共成员'Count'。 [英] Public member 'Count' on type 'String()' not found.
问题描述
我在下面显示的代码上收到上述错误消息。代码在公共函数中,我在页面上有正确的import语句(Imports System.Linq)。无论我做什么,我都无法在没有错误消息的情况下通过这段代码。任何建议都将不胜感激。
如果 sBreadcrumb.Split( 。)。计数> 1 然后
root = CInt (sBreadcrumb.Split( 。)( 1 ))
oPage = 新 SiteManagerPage( CInt (root), Nothing )
结束 如果
尝试如果是sBreadcrumb.Split(。)。长度> 1然后
数组
类型不支持计数
属性。
仅集合,列表,...
类型支持计数
物业。
使用长度
属性而不是计数
about数组
类型。
你错过了()
,
如果sBreadcrumb.Split( 。)。< u> Count() > 1 然后
root = CInt(sBreadcrumb) .Split( 。)( 1 ))
oPage =新SiteManagerPage(CInt(root),Nothing)
结束如果
请注意Count()
扩展方法可以与IEnumerable
一起使用,但Collection类型有Count
属性和数组类型有长度
属性。 大多数集合都有一个更有效的长度或计数属性。
何时使用Count()。这种扩展方法确实有一些很好的用途。如果你使用LINQ查询表达式,或者由于其他原因有一个IEnumerable实例,那么它是确定存在多少元素的最佳方法。
Count方法可以与Func类型的参数一起使用。例如:
Dim greaterThanTwo As Integer = array.Count(Function(element)element > 2 跨度>)
I am getting the above error message on the code shown below. The code is in a public function and I do have correct import statement on the page (Imports System.Linq). No matter what I do I can't get past this bit of code without the error message. Any suggestions would be greatly appreciated.
If sBreadcrumb.Split(".").Count > 1 Then
root = CInt(sBreadcrumb.Split(".")(1))
oPage = New SiteManagerPage(CInt(root), Nothing)
End If
Try If sBreadcrumb.Split(".").Length > 1 Then
Array
Type does not supportCount
Property.
OnlyCollection, List, ...
Type does supportCount
Property.
UseLength
property insteadCount
aboutArray
Types.
You missed()
,
If sBreadcrumb.Split(".").Count() > 1 Then root = CInt(sBreadcrumb.Split(".")(1)) oPage = New SiteManagerPage(CInt(root), Nothing) End If
Note thatCount()
extension method can be used withIEnumerable
but Collection types there isCount
property and for array types there isLength
property. Most collections have a Length or Count property that is more efficient.
When to use Count(). This extension method does have some good uses. If you use a LINQ query expression, or for some other reason have an IEnumerable instance, it is the best way to determine how many elements are present.
The Count method can be used with an argument of type Func. e.g.:
Dim greaterThanTwo As Integer = array.Count(Function(element) element > 2)
这篇关于未找到类型'String()'上的公共成员'Count'。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!