One possible method to group using the outcome of an asynchronous Task<string> and receive a grouping by string in C# is as follows:
List<Task<string>> tasks = new List<Task<string>>()
{
GetStringAsync("foo"),
GetStringAsync("bar"),
GetStringAsync("baz"),
};
Task<string>[] results = await Task.WhenAll(tasks);
var groups = results.GroupBy(s => s[0]);
foreach (var group in groups)
{
Console.WriteLine("{0}: {1}", group.Key, group.Count());
}
This will produce output like the following:
f: 1
b: 2
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-10-21 11:00:00 +0000
Seen: 11 times
Last updated: Sep 19 '22
How can individuals be added to a Telegram group?
What is a simple method to duplicate and rename a group of connected ADF Pipelines?
How can Azure RBAC be assigned to a security group in Azure AD at the level of a resource group?
"How can I isolate a particular class from a group of classes?"
How can Twig loops be organized into groups?
What steps can be taken to turn a Cog into a command group with a prefix?
How can nodes be grouped in a Chord diagram using Holoviews?