Interchange/Swap column Values using Linq

Problem statement: We need to interchange the values in the ‘Gender’ column in the Employee Datable

E.g. Replace ‘Male’ Value with ‘Female’ and ‘Female’ value with ‘Male’ in the ‘Gender’ column in a Employee Datatable.

Datatable1

Here is the code

WriteThecode

Run the code and see the magic

Youtube Link : Swap Column Values in a Datatable using LINQ in UiPath - YouTube

Code Link :slight_smile: manojbatra071/UiPathSamples (github.com)

1 Like

@Manoj_Batra we can do with just one if statement
dt_sheet9.AsEnumerable().ToList().ForEach(Sub(row) row(“Gender”)=If(row(“Gender”).ToString.Contains(“M”),“F”,“M”))

@Naveen_Mohandas This is what I explained above
image