My company is using a piece of software developed by another company. Their software has an API to add/remove documents from their system. They've given us a sample written in C#, and I'm in the process of converting it to VB. I'm stuck trying to understand one thing. They have the following:
Here is what I came up with:
Three lines of code vs. Nine lines of code... It works, but is there a better way to do this in VB? What would be the syntax to add the attributes on the fly, without having to dim a new attribute variable for each attribute?
Thanks in advance...
mwa
<><
Code:
List<DocAttribute> metadata = new List<DocAttribute>();
metadata.Add(new DocAttribute() { Name = "DocumentType", Value = txtDocType.Text});
metadata.Add(new DocAttribute() { Name = "SSN", Value = txtSsn.Text});
Here is what I came up with:
Code:
Dim metadata As List(Of DocAttribute) = New List(Of DocAttribute)
Dim attribute As New DocAttribute
Dim attribute2 As New DocAttribute
attribute.Name = "DocumentType"
attribute.Value = txtDocType.Text
metadata.Add(attribute)
attribute2.Name = "SSN"
attribute2.Value = txtSsn.Text
metadata.Add(attribute2)
Three lines of code vs. Nine lines of code... It works, but is there a better way to do this in VB? What would be the syntax to add the attributes on the fly, without having to dim a new attribute variable for each attribute?
Thanks in advance...
mwa
<><