I have a Data Table created which has the last column as a List of Strings.
Then I fill the Data Table with some data, including the lists of strings, but then, I am trying to access the data and I cannot understand how do I iterate through the lists of strings in each row:
I’ve tried to create a dataTable with the a String[] in one of its columns but I was unable to add any data to it directly in the build table or with add data row activity I think this problem needs more investigations
As the error message says, the compiler doesn’t know that what you have in the sixth column (row.item(5)) is an array of strings, since the method that gets the data from the DataTable row says it’s an Object.
There are two ways of fixing your problem.
The first one is to tell the compiler to treat that object as an array of strings, since you know for sure that is what you put into that cell. (Note that this will blow up with an error if the Object is not actually an array of strings or if it isn’t actually there - it’s Nothing/null. Also note that an empty list will work fine, but it shouldn’t be confused with a null)
Forcefully “telling” the compiler what’s the data type of a variable/expression is called type casting. In your case you could use TryCast or DirectCast (more about them here: https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/operators/trycast-operator ) so instead of row.Item(5) you could say TryCast(row.Item(5), String())
This is how it would look (I also added an intermediate variable catsList of type String):
The second option, and the one I actually recommend is to access the array value through the Field() method instead of the Item() method, like this: row.Field(Of String())(5)