大家好,我已经能够弄清楚如何从.net web 服务简单地发送一个类。
这是我的课
Imports Microsoft.VisualBasic
Public Class TestClass
Public Class Person
Public Class Names
'Public Property Firsname As String
Public Property ID As Integer
Public Property LastName As String
Shared Property FirstName As String
End Class
End Class
End Class
这是我在代码中使用它的方式,
<WebMethod()> _
Public Function PersonList(ID As Integer) As List(Of Person.Names)
'Dim p As New Person With {.ID = ID, .FirstName = "Kenneth"}
Try
Dim ListPerson As New List(Of Person.Names)
For startNumber = 1 To 4
Dim Per As New Person.Names
Per.ID = startNumber
ListPerson.Add(Per)
Next
Return ListPerson
Catch ex As Exception
Dim Per As New Person.Names
Per.ID = ex.Message
Dim ListPerson As New List(Of Person.Names)
ListPerson.Add(Per)
End Try
End Function
这在我返回 JSON 时效果很好,但现在我想更进一步。我想要有列表的列表。这可能吗。
看看这张图片。
我想返回一个低于 id 的数组,而不仅仅是 id 的值。我该怎么做?