# For loop inside Assign

**URL:** <https://forum.uipath.com/t/for-loop-inside-assign/352651>\
**Category:** Studio\
**Tags:** question, system, activities\
**Created:** [October 13, 2021, 8:57am UTC](https://forum.uipath.com/t/for-loop-inside-assign/352651 "2021-10-13T08:57:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmedinacarbonell](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jmedinacarbonell/32/406304_2.png) [@jmedinacarbonell](https://forum.uipath.com/u/jmedinacarbonell)\
**Post date:** [October 13, 2021, 8:57am UTC](https://forum.uipath.com/t/for-loop-inside-assign/352651/1 "2021-10-13T08:57:55Z")

</div>

Hi there,

Previously:  
I was recently researching for something else and I found someone doing it …  
I tried to find it now, when I need it (as usual 😃 ) and I couldn’t so, I decided to dedicate a post.

Decription:  
I would like to insert a For/For each loop inside an assign activity, something like this:

 ![image](https://global.discourse-cdn.com/uipath/original/3X/b/3/b3911c5aa3d4116b487c993cab5b52045288e214.png)

This is an example where Im trying to get all the column names from a dt and directly convert it to an Array variable

Do you know the syntax?

Thank you in advance family!

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [October 13, 2021, 9:08am UTC](https://forum.uipath.com/t/for-loop-inside-assign/352651/2 "2021-10-13T09:08:10Z")

</div>

> [@jmedinacarbonell](#):
>
> rying to get all the column names from a dt and directly convert it to an Array variable

We can do it with LINQ

Method Syntax  
dtData.Columns.Cast(Of DataColumn).Select(Function (x) x.ColumnName).toArray

Query Syntax:  
(From c in dtData.Columns.Cast(Of DataColumn  
Select n=c.ColumnName).toArray

> [@\[HowTo\] LINQ (VB.Net) Learning Catalogue](https://forum.uipath.com/t/howto-linq-vb-net-learning-catalogue/325671):
>
> This topic references the different Learning HowTos related to LINQ. It will be updated on new published HowTos as well LINQ Learning: Topic LINK First Start with LINQ [[HowTo] - First Start with LINQ (VB.Net)](https://forum.uipath.com/t/howto-first-start-with-linq-vb-net/318964/) Exploring the LINQ universe [[HowTo] - Exploring the LINQ Universe (VB.Net)](https://forum.uipath.com/t/howto-exploring-the-linq-universe-vb-net/325667)Operator [HowTo] Overview Topic LINK Where [[HowTo] LINQ - First Start # Where Operator](https://forum.uipath.com/t/howto-linq-first-start-where-operator/464108) Select work in progress Any [[HowTo] LINQ – First Start # Any Operator](https://forum.uipath.com/t/howto-linq-first-start-any-operator/466138) All [[HowTo] LINQ – First Start…](https://forum.uipath.com/t/howto-linq-first-start-all-operator/467292)

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [October 19, 2021, 10:39am UTC](https://forum.uipath.com/t/for-loop-inside-assign/352651/3 "2021-10-19T10:39:02Z")

</div>

Closed on October 19, 2021, 10:39am UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
