Good Morning,
For such a simple loop (although the input object could have hundreds of items) would Linq be any faster or would the compiler just create the same basic loop out of the Linq statements?
Any ideas?
TIA
public static string ConcatWithDelimiter(object[] input, string prop, string delimiter)
{
List<FDXCategory> categories = new List<FDXCategory>();
var j = input.Select(i => i.ToString()).ToList();
foreach (var VARIABLE in j)
{
var x = JsonConvert.DeserializeObject<FDXCategory>(VARIABLE);
categories.Add(x);
}
switch (prop)
{
case "Id":
return categories.Select(c => c.Id).Aggregate((a, b) => a + delimiter + b);
case "Name":
return categories.Select(c => c.Name).Aggregate((a, b) => a + delimiter + b);
}
return "Invalid Property Name";
}