John Nero John Nero - 5 months ago 21 Question

Why value of type list(of integer) cannot be converted to integer ?why i am not able to send list value to wcf service?please Solve this

Client code:

Public Sub sendEmpValue(name As String, value As List(Of Integer))
Dim serviceObject As New Service.GetEmployeeClient
serviceObject.DoWork(name, value)** getting error at the value**
End Sub

Service code:

Sub DoWork(name As String, value As List(Of Integer)) Implements IGetEmployee.DoWork
End Sub

screenshot of the error


The DoWork method expects an Integer() which is an array of integers.

The List(Of T) class has got a function called ToArray() which will return the list as an array. Call that and it should work.

serviceObject.DoWork(name, value.ToArray())

Read more about arrays on the MSDN documentation.

According to this answer when using WCF a List(Of T) is converted into an array on the clientside, which is why the DoWork method wants an array instead of a List(Of Integer) as you've specified. This behaviour can apparently be modified though.