Browsing 7239 questions and answers with Jon Skeet
You'd usually want to use the IQueryable form, so that the filtering is done on the database instead of locally. The code you've got will pull all records down to the client, and filter them there - that's extremely inefficient. You... more 3/3/2015 11:35:17 AM
Is the vector class not synchronized on its own object (this)? Yes, but only for each individual operation. Here we have two operations: if (vector.isEmpty()) vector.add(anElement); It's possible that between the check of... more 3/3/2015 10:33:44 AM
No, the generic type definition will refer to ICollection<T> specifically, where T is the type parameter for the IList<T>. Imagine you had something like: public class Foo<T1, T2> : IEnumerable<T1>,... more 3/3/2015 9:57:27 AM
I am able to create the object of class1 but not of class2, Why So? Two reasons: Firstly, Class1 is implicitly internal, whereas Class2 is implicitly private (because it's nested). Secondly, you're trying to use just Class2 in a... more 3/3/2015 8:24:22 AM
It should be in try, for two reasons: You'll commit the session if some exception or error other than a HibernateException, and you almost certainly don't want to do that You'll call commit after calling rollback. I can't remember... more 3/3/2015 7:07:28 AM
There's nothing special about LINQ here - you basically write the same code as you would normally, using is or as: string searchText = searchBar.Text; profileListsForSearch = profileLists .Where(profile => profile is... more 3/3/2015 6:59:45 AM
You're going in one level too deep - trans is already a Data element, you're then ordering the elements within Data... by a TimeEventStart element within each of those subelements... and that doesn't exist, because TimeEventStart is a... more 3/2/2015 9:49:32 PM
Despite the various comments, I've seen helper methods like this used quite a bit, for static initialization, and usually found them simpler than alternatives. Of course, it only works when your key and value type are the same - otherwise... more 3/2/2015 7:27:07 PM
As it's sorted, you can use a binary search to try to find an exact match. If List<T>.BinarySearch returns a non-negative number, you know you've found an exact match. Otherwise, you can apply the bitwise complement operator to find... more 3/2/2015 7:13:05 PM
You've fallen foul of lazy evaluation - the result of Select will create a new set of tasks each time you iterate over it. You can fix this just by calling ToList(): var tasks = _factory.CreateMessage(settings) ... more 3/2/2015 4:38:25 PM