Exam UiPath-ADPv1 Topic 3 Question 41 Discussion
Actual exam question for UiPath's UiPath-ADPv1 exam
Question #: 41
Topic #: 3
Question #: 41
Topic #: 3
The following table is stored in a variable called "dt".

Which query can be used to extract the table column names and store them in a list?

Which query can be used to extract the table column names and store them in a list?
Suggested Answer: A Vote an answer
The DataTable object in UiPath is a representation of a table with rows and columns that can store data of various types. It has a Columns property that returns a collection of DataColumn objects that describe the schema of the table1. To extract the column names from a DataTable and store them in a list, you can use the following query:
dt.Columns.Cast(Of Datacolumn).Select(function(x) x.ColumnName).ToList() This query does the following:
It casts the Columns collection to a generic IEnumerable(Of DataColumn) using the Cast(Of T) extension method2. This is necessary because the Columns collection is a non-generic IEnumerable that cannot be used with LINQ methods directly3.
It selects the ColumnName property of each DataColumn object using the Select extension method and a lambda expression4. The ColumnName property returns the name of the column as a string5.
It converts the resulting IEnumerable(Of String) to a List(Of String) using the ToList extension method6.
The other options are incorrect because:
Option B does not cast the Columns collection to a generic IEnumerable(Of DataColumn), which will cause a runtime error.
Option C uses the AsEnumerable extension method, which returns a collection of DataRow objects, not DataColumn objects7. Therefore, the ColumnName property will not be available.
Option D selects the whole DataColumn object instead of its ColumnName property, which will result in a list of DataColumn objects, not strings.
References:
DataTable Class (System.Data) | Microsoft Docs
Enumerable.Cast(Of TResult) Method (System.Linq) | Microsoft Docs
DataColumnCollection Class (System.Data) | Microsoft Docs
Enumerable.Select(Of TSource, TResult) Method (System.Linq) | Microsoft Docs DataColumn.ColumnName Property (System.Data) | Microsoft Docs Enumerable.ToList(Of TSource) Method (System.Linq) | Microsoft Docs DataTableExtensions.AsEnumerable Method (System.Data) | Microsoft Docs
dt.Columns.Cast(Of Datacolumn).Select(function(x) x.ColumnName).ToList() This query does the following:
It casts the Columns collection to a generic IEnumerable(Of DataColumn) using the Cast(Of T) extension method2. This is necessary because the Columns collection is a non-generic IEnumerable that cannot be used with LINQ methods directly3.
It selects the ColumnName property of each DataColumn object using the Select extension method and a lambda expression4. The ColumnName property returns the name of the column as a string5.
It converts the resulting IEnumerable(Of String) to a List(Of String) using the ToList extension method6.
The other options are incorrect because:
Option B does not cast the Columns collection to a generic IEnumerable(Of DataColumn), which will cause a runtime error.
Option C uses the AsEnumerable extension method, which returns a collection of DataRow objects, not DataColumn objects7. Therefore, the ColumnName property will not be available.
Option D selects the whole DataColumn object instead of its ColumnName property, which will result in a list of DataColumn objects, not strings.
References:
DataTable Class (System.Data) | Microsoft Docs
Enumerable.Cast(Of TResult) Method (System.Linq) | Microsoft Docs
DataColumnCollection Class (System.Data) | Microsoft Docs
Enumerable.Select(Of TSource, TResult) Method (System.Linq) | Microsoft Docs DataColumn.ColumnName Property (System.Data) | Microsoft Docs Enumerable.ToList(Of TSource) Method (System.Linq) | Microsoft Docs DataTableExtensions.AsEnumerable Method (System.Data) | Microsoft Docs
by Dick at Jul 15, 2026, 01:08 AM
0
0
0
10
Comments
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Report Comment
Commenting
You can sign-up / login (it's free).