Hi
I have two arrey variables one is name and other one is Address now i want to add them in one datatable like the way address match to the name .
Are those array variables already aligned ? Means does the first entry on the name array variable equates to first entry in address array variable?
If yes, you can simply run a loop on the array variable count and have the datatable values assigned inside the loop. Before the loop have the datatable created using build datatable activity and provide 2 columns name and address there. Then inside loop, assign values like
Dt(0)(“Name”) = arr1(0)
Dt(0)(“Address”) = arr2(0)
Replace 0 with the counter variable.
Hope this helps.
Assumptions :
NamesArr = {“name1”,“name2”,“name3”,“name4”}
AddressArr ={“name1,1,street1,IND”,“name2,2,Street2,PH”,“name3,3,street3,TH”,“name4,4,street4,JP”}
//
1.Create a datatable and add two columns {“name”,“Address”}) (say Dt_Input)
foreach(name in NamesArr)
{
dtRow= Dt_Input.NewRow();
dtRow.ItemArray = New Object() {name,AddressArr.Where(Function(x) x.Contains(name)).ToArray()(0)}; //checks if any of the addresses contain the name
Dt_Input.Rows.Add(dtRow);
}
hope you can relate to the assumptions!
regards
SG.
- Build datatable , add two columns in it name and address
- For each on ArrayName
- inside loop use add data row with item array as
New Object(){currentItem,ArrayAddress(currentindex)}
it would either be index or currentindex check in the loop
cheers
@Anil_G Thanks for your reply I did it already i use the same method as you described . Thanks for your support
@sonaliaggarwal47 Thanks for your support I use this method and it is working fine
- Build datatable , add two columns in it name and address
- For each on ArrayName
- inside loop use add data row with item array as
New Object(){currentItem,ArrayAddress(currentindex)}
Happy Automation