我收到以下错误Class 'PropGenie_WebService.Branch' cannot be indexed because it has no default property.
而且我不确定原因。我用谷歌搜索,但没有得到适当的解释或修复。 C#help welcome。
我在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
答案 0 :(得分:2)
您需要指定共享函数所在的类,或者它将尝试在您所在的对象中使用Update
函数。
Public Function Update() As Branch
Return Resources.Update(Me, Path)
End Function