Browsing 7239 questions and answers with Jon Skeet
The problem is that your two Inside types are currently unrelated - there's no way for X.doSomeWork() to do refer to "it's this type or that type" when they're entirely different types. The fact that they're both nested classes called... more 3/22/2014 8:22:05 AM
It's not a matter of convention - it's a matter of what's logical state in the object. If a variable is logically part of the state of an object, it should be declared as a field - and yes, conventionally put at the top of the file. If... more 3/21/2014 8:14:18 PM
It sounds like you're expecting overload resolution to occur at execution time. That doesn't happen... unless you use dynamic, which may well be the simplest solution for you: dynamic order = GetOrder(orderId); HandleOrder(order); // The... more 3/21/2014 5:24:06 PM
You're only generating one number in the range 1-15. You're then generating subsequent numbers with just nextInt: if (myNumbers.add(randNum)) break; else randNum = randGen.nextInt(); That should be: if (myNumbers.add(randNum)) ... more 3/21/2014 4:01:20 PM
I suspect you just want a combination of [SelectMany]1 (to flatten the document list to a document group sequence) and then Distinct to get the distinct elements: var documentGroups = documentList.SelectMany(d => d.DocumentGroups) ... more 3/21/2014 3:29:36 PM
This isn't valid Java: Long Timestamp1[i] = // anything... It's not really clear what you're trying to do - if you're trying to populate a single element of an existing array, you should use: Timestamp1[i] = ... If you're trying to... more 3/21/2014 3:21:40 PM
Misread the question. Given that every type in Java is either a primitive, an interface, a class, or an array, you just need: System.out.println(!b.isPrimitive() && !b.isInterface() && !b.isArray()); That treats enums as... more 3/21/2014 2:51:25 PM
Comparator is a functional interface, and Integer::max complies with that interface (after autoboxing/unboxing is taken into consideration). It takes two int values and returns an int - just as you'd expect a Comparator<Integer> to... more 3/21/2014 2:35:23 PM
Normaly, you would just use protected, which does work within subclasses within the restrictions in the JLS: In foo/Parent.java: package foo; public class Parent { protected int x; } In bar/Child.java: package bar; import... more 3/21/2014 2:15:24 PM
It's just an endian-ness issue. You can use my MiscUtil library to read big-endian data from .NET. However, I would strongly advise a simpler approach to both your Java and your .NET: In Java, use DataInputStream and DataOutputStream.... more 3/21/2014 1:42:39 PM