0

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.

2
  • 1
    how can an array of string be assigned to a string? you might want to use array index to assign to a string Commented Nov 22, 2013 at 5:57
  • So previously it was something like this oDocument.FundServCodes = lstFundServCodes.ToArray() and FundServCodes is String while lstFundServCodes is same List(of String) Commented Nov 22, 2013 at 6:00

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.