How to initiazle list of datacolumn

How to initiazle list of datacolumn

Hi @Demo_User

You can try the following expression:

columnList = New List(Of DataColumn)()

Then, to add columns:

columnList.Add(New DataColumn("Col1"))
columnList.Add(New DataColumn("Col2"))

Hope this helps,
Best Regards.

myList = new List(of DataColumn)

Which value should i assign

Getting a error as doesnot produce a value

@Demo_User

The data type of the variable ‘columnList’ will be List<DataColumn>

Best Regards.

Getting the error as expression doesnot produce a value

@Demo_User

Please look into the expression again, you should be getting this:

Variable data type:

Best Regards.

columnList.Add(New DataColumn(“Col1”))
columnList.Add(New DataColumn(“Col2”))
Getting error in this expression

@Demo_User

You need to use those expressions in the Invoke Code activity to add the columns to the list:

Hope this helps,
Best Regards.

Hi @Demo_User

  1. Assign activity:

columnList = New List(Of DataColumn)

  1. Use Add To Collection activity (repeat for each DataColumn):

Collection: columnList
Item: New DataColumn(“col1”, GetType(String))

Collection: columnList
Item: New DataColumn(“col2”, GetType(Integer))

Collection: columnList
Item: New DataColumn(“col3”, GetType(DateTime))

Hope it helps!!
Regards,

the Add method is a so called sub (subroutine) and will not return a value. When used this within an Assign Activity you will get this error

When adding items to a list we can:

  • use activities like Append Item to collection / Append item to List
  • some LINQs

Or also we can do it this lazy way

Assign Activity
myColList = new DataColumn(){New DataColumn("Col1"),New DataColumn("Col2")}.toList()