I randomly sorted an IEnumerable. I keep printing out the same element, and getting a different result.
I am using LINQ: Desired result: I tried but fail: How can I do this using LINQ? This works, even if I am not sure why you need it as linq expression:
When profiling one of our applications, we discovered a mysterious slowdown in some code where we were calling Enumerable.Single(source, predicate) for a large collection that had more than one item that matched the predicate near the start of the collection.
I thought I know everything about IEnumerable<T> but I just met a case that I cannot explain. When we call .Where linq method on a IEnumerable, the execution is deferred until the object is enumerated, isn't it?
I have a c# class that looks like thisI extend this class something like thisI need to use reflection to find all classes that extend the Listener<> base class.
I have castedand I would like to see if this enumerable has any elements, via using Linq Query Any(). But unfortunately, even with using Linq, I can't.
Does anyone knows what the Linq code is for the following code?:Use SelectMany to flatten nested lists
I have two classes:In a method which should returns an object of type Table, I try to filter an object of type Table with the Where-Statement and return this object after filtering.
I have the following object:I need to find a list of all the objects (List< MyObj >) in the inner list, that has ID equal 1.
I have an IEnumerable of a certain object which has a bool property. I would like to count for how many objects this property is set to true in a compact (in terms of code lines) and readable way.