Linq query to get length of one column into a

Hi all, i’m trying to get the length of one column to another new column using Linq can you please help me

@Amrutha.mg

dtWithLength = (From row In dt.AsEnumerable()
Let length = row.Field(Of String)(“TextColumn”).Length
Select dt.Clone().Rows.Add(row.ItemArray.Append(length).ToArray())).CopyToDataTable()

hi i want to add the length value to column3 of the same datatable

Hi @Amrutha.mg ,

Could you explain a bit more as to what is required maybe with an Example so that we can be clear on the requirement.

consider a datatable with 3 columns we have to take the length of column 1 value and update it to column 3

@Amrutha.mg ,

Maybe check with the below method using Data Column Expression as it is a Simple operation :

DT.columns("Length").Expression = "Len([Text])"

Implementation :
image

Debug Visuals :
image

Do also check the links below :

Thank you for your help

1 Like

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