I need to call a C++ routine with a KeyValuePair parameter. I have an example in C#;
KeyValuePair[] dataArray =
new KeyValuePair[]{
new KeyValuePair() { key = 1234, value = "Atlanta" },
new KeyValuePair() { key = 70, value = "Atlanta" },
new KeyValuePair() { key = 2320, value = "999999999" }};
This seems to translates to;
Dim dataArray As KeyValuePair() = New KeyValuePair() {New KeyValuePair() With {
.key = 1234,
.value = "Atlanta"
}, New KeyValuePair() With {
.key = 70,
.value = "Atlanta"
}}
in VB.
I have two questions;
What is this structure called? I would call it an array of KeyValuePairs. So I know how to reference the structure when I search.
How does one add additional values dynamically?
EDIT:
More specifically I have a function whose purpose is to build the same type of structure statically built in the C# code above by reading values from a database. I had originally written the code assuming the "list of" key value pairs is what I needed. Here is that code;
Private Function buildDataRecord(ByRef objRecord As OracleDataReader) As List(Of KeyValuePair(Of Integer, String))
Dim i As Integer = 0
Dim lstFieldData As List(Of KeyValuePair(Of Integer, String)) = New List(Of KeyValuePair(Of Integer, String))
Dim strFieldName As String
On Error GoTo buildDataRecordError
For i = 0 To objRecord.FieldCount - 1
strFieldName = objRecord.GetName(i)
If strFieldName.Substring(0, 3) = "IN_" _
Then
lstFieldData.Add(New KeyValuePair(Of Integer, String)(CInt(strFieldName.Substring(3)), Trim(objRecord(i).ToString)))
End If
Next
Return lstFieldData
buildDataRecordError:
Err.Raise(Err.Number,
"buildDataRecord",
Err.Description,
Err.HelpFile,
Err.HelpContext)
When calling C++ I get the error;
Cannot marshal 'parameter #4': Generic types cannot be marshaled.
My assumption is I do not have the correct data type.