Creating the IEnumerable Objects with C#?

any of: values = new Dictionary<string,string> { {“Name”, “John”}, {“City”, “NY”} }; or values = new [] { new KeyValuePair<string,string>(“Name”,”John”), new KeyValuePair<string,string>(“City”,”NY”) }; or: values = (new[] { new {Key = “Name”, Value = “John”}, new {Key = “City”, Value = “NY”} }).ToDictionary(x => x.Key, x => x.Value);

What’s the Best Way to Add One Item to an IEnumerable?

Nope, that’s about as concise as you’ll get using built-in language/framework features. You could always create an extension method if you prefer: arr = arr.Append(“JKL”); // or arr = arr.Append(“123”, “456”); // or arr = arr.Append(“MNO”, “PQR”, “STU”, “VWY”, “etc”, “…”); // … public static class EnumerableExtensions { public static IEnumerable<T> Append<T>( this IEnumerable<T> source, … Read more

How to append enumerable collection to an existing list in C#

Well, something will have to loop… but in LINQ you could easily use the Concat and ToList extension methods: var bigList = list1.Concat(list2).Concat(list3).ToList(); Note that this will create a new list rather than appending items to an existing list. If you want to add them to an existing list, List<T>.AddRange is probably what you’re after: … Read more

What is difference between push based and pull based structures like IEnumerable and IObservable

Please in a normal and human way explain to me the difference OK, let’s make some toast. That’s the most normal human thing I do. Pull based: // I want some toast. I will pull it out of the toaster when it is done. // I will do nothing until the toast is available. Toast … Read more