Class' cannot be indexed because it does not have a default property

I get the following error Class 'PropGenie_WebService.Branch' cannot be indexed because it has no default property.And I'm not sure why. I have googled, but do not get the right explanation or correction. C # help is welcome.

My code in the branch.vb class:

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

And in my base class (Resources.vb) I have:

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
+4
source share
1 answer

You need to specify the class in which the shared function is located, or try to use the function Updatein the object you are in.

Public Function Update() As Branch
    Return Resources.Update(Me, Path)
End Function
+2
source

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


All Articles