I need to create a list with different datatypes element, for example:
{{10, 10}, "IT", 1, "Test", {100, 100}, "Test"}
respectively:
{object, string, integer, string, object, string}
I have tried declaring it as list of objects or using Tuple(Of Object, String, Integer, String, Object, String)
but when I give them the values,
“Array initializer has too few dimensions”
error occurs.
The class where the variable is declared:
Public Class SignatureResponse
Public signature As Tuple(Of Object, String, Integer, String, Object, String)
Sub New()
Me.signature = Nothing
End Sub
Sub New(ByVal signature As Tuple(Of Object, String, Integer, String, Object, String))
Me.signature = signature
End Sub
End Class
The class to which I use the parameter and assign the values:
Public Class Signature
Inherits System.Web.Services.WebService
<WebMethod()>
<ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=False, XmlSerializeString:=False)>
Public Function SendIdDocuments(ByVal idDocument As String, ByVal content As String, ByVal userId As String)
Dim respDocs As New SignatureResponse
respDocs.signature = {{10, 10}, "IT", 1, "Testing", {100, 100}, "Test Signature"}
'Other part of development
JSONString = JsonConvert.SerializeObject(respDocs)
Return JSONString
End Function
End Class
I am sending just the more important part of the code, they are more parameters used that works perfectly, except this one.
Any help please?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
If you’re using the old Tuple syntax as above then you can’t create a new one in the way you’ve shown. You have to do:
respDocs.signature =
New Tuple(Of Object, String, Integer, String, Object, String)({10, 10}, "IT", 1, "Testing", {100, 100}, "Test Signature")
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0
