dna
dna

Reputation: 483

value of 1 dimensional array of string cannot be converted to String

I am trying to assign values of array to a string, following is the code:

oDocument1.IdentifierCode = lstFundIdentifiers.ToArray()

where IdentifierCode is a string while lstFundIdentifiers is declared as

ByVal lstFundIdentifiers As List(Of String).

I am not sure as to what is going wrong.

Upvotes: 0

Views: 9077

Answers (1)

Yatrix
Yatrix

Reputation: 13795

String <> String()

Trying to assign an array to a string is like trying to put 4 tires on a unicycle. An array (or list) is a collection of objects, in your case, strings.

You can do this: yourArray(1) = yourString or yourString = yourArray(0), but you can't do this: yourString = yourArray.

EDIT in response to your comment:

"So previously it was something like this oDocument.FundServCodes = lstFundServCodes.ToArray()"

FundServCodes is an array itself, which is why that would work. You can easily confirm this by going to the class and looking at the FundServCodes property.

EDIT 2:

These are basic programming concepts. Maybe you should go read up on collections, data types, objects, etc. There are 1000's of programming books and tutorials for all skill levels out there. Look one up and go through it.

Upvotes: 2

Related Questions