Browsing 7239 questions and answers with Jon Skeet
If this is in LINQ to Objects, you could just use: .OrderBy(g => x.First().cat.order) Alternatively, you could group by both the name and the order, then use the order part of the key: .GroupBy(x => new { x.cat.name, x.cat.order... more 6/5/2014 10:07:36 AM
You can create an internal constructor in XX: public abstract class XX { internal XX() { } } (Or if you already have explicitly-declared constructors, make them all private or internal.) That will prevent any other... more 6/5/2014 9:26:05 AM
AgentFire's answer is effectively appropriate, but a bit long-winded to special-case in each situation. I'd add an extension method: EDIT: Apparently, the code below doesn't correctly determine whether the query is already ordered; even... more 6/5/2014 8:43:55 AM
I have no idea why here needs to assign the "l" to "temp" He's not - that would just be: ArrayList<Integer> temp = l; Instead, the code creates a copy of the content of the list l refers to, in a new ArrayList. That means... more 6/5/2014 6:04:39 AM
The object I am trying to cast to lives in my main application It's not entirely clear what you mean by that, but the object you're trying to cast is just an instance of System.Object: (T)new object() That can never work unless T... more 6/5/2014 6:01:20 AM
Look at your command-line: java -cp /Users/dj/Library/Java/Extensions/junit-4.11.jar org.junit.runner.JUnitCore You've got the JUnit jar file on your class path - but not the current directory. So it won't be able to find any classes... more 6/4/2014 6:42:26 PM
ReadOnlyDictionary was introduced in .NET 4.5. Now .NET 4.5 is an "over the top" install, which is why you're seeing it in your version of mscorlib. However, if your project is targeting .NET 4.0, then presumably Visual Studio has some... more 6/4/2014 3:16:58 PM
Okay, now we know how you're writing the file, this is the problem: FileWriter w = new FileWriter("D:\\outtest.xml"); That will always use the platform-default encoding - even though you've told JAXB that you're going to be using UTF-8.... more 6/4/2014 1:51:09 PM
It's not at all thread-safe at the moment. You can use Interlocked.Increment(ref count) instead, but it's generally better to have a "local" value for each thread, and sum them at the end. That way you don't need to have any sort of... more 6/4/2014 1:44:02 PM
The problem is that your getCategories method returns a List<Object>, when it would make more sense for it to return List<Category>: public List<Object> getCategories() throws Exception{ // Note: this is now a... more 6/4/2014 11:22:09 AM