A quick example of how to use the Aggregate method to create a string of delimited members, or in this case characters. You might wonder why this example, or at least you should. It’s true, the character list to delimited string is pretty useless, but some idiot from where I work needed it.
[TestMethod] public void GetStringFromCharacters() { var charList = Enumerable.Range(0, 10).Select(x => 'a').ToList(); charList .Aggregate("", (inner, outer) => inner + outer.ToString() + ",") .Should() .Be("a,a,a,a,a,a,a,a,a,a"); }
The big thing here is the “” in the Aggregate method signature. That basically says that Inner is a string. If I didn’t have that specified, both inner and outer would be a character.
YAY
I’m glad that idiot needed it! Â I just used it too.