vb.net – Class’无法编入索引,因为它没有默认属性

我得到以下错误类’PropGenie_WebService.Branch’无法编入索引,因为它没有默认属性.而且我不确定为什么.我用谷歌搜索,但没有得到适当的解释或修复. C#帮助欢迎.

我在branch.vb类中的代码:

Public Function Update() As Branch
    Return Update(Me, Path) 'error at update.
End Function

在我的Base类(Resources.vb)中,我有:

Public Shared Function Update(Of T As {Resources, New})(resource As T, path As String) As T
        Dim request = CreateRequest(path & "/{id}", Method.PATCH)
        request.AddUrlSegment("id", resource.Id.ToString(CultureInfo.InvariantCulture))
        request.AddBody(resource)
        Dim Client = CreateClient()
        Dim responce = Client.Execute(Of T)(request)
        If responce.StatusCode <> HttpStatusCode.OK Then
            Throw New InvalidOperationException("Update Failed" & Convert.ToString(responce.StatusCode))
        End If
        Return responce.Data
    End Function

最佳答案 您需要指定共享函数所在的类,或者它将尝试在您所在的对象中使用Update函数.

Public Function Update() As Branch
    Return Resources.Update(Me, Path)
End Function
点赞