@Binumon George , you could try the following code to use string interpolation to replace string + concatenation.
int itemsCount = list.Count();
int loopCount = 0;
string query = string.Empty;
foreach (string oVarItem in list)
{
loopCount++;
string[] oArrList = oVarItem.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
if (loopCount != itemsCount)
{
query=$"{query}{oArrList[1]}: '{oArrList[3].ToString()}',";
}
else
{
query=$"{query}{oArrList[1]}: '{oArrList[3].ToString()}'}}) return id(a)";
}
}
Based on my test, I can get the same result with the code you provided.
Best Regards,
Jack
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.