Browsing 7239 questions and answers with Jon Skeet
Not like that, no - but you can write: return preventivos.Where(predicate).Select(...); ... although your code example seems to be unclear as to whether this is really generic or whether it only deals with Preventivos. The point is... more 5/7/2015 1:59:53 PM
Well it's better in that having public fields is almost always a bad idea, particularly for mutable objects. However, it's definitely still not thread-safe. Two threads could absolutely call the method and end up using the formatter at... more 5/7/2015 1:47:26 PM
I think that (String)x is an unchecked cast No, it's not. It's checked at execution time - if the cast isn't valid, it will throw an exception. Unchecked casts are about casts that look like they'll do checking, but actually don't... more 5/7/2015 12:59:28 PM
Yes, you're creating an Object[] and then trying to cast it to T[], which the compiler is converting to a cast to Comparable[] (using the raw Comparable type) due to your constraint on T. Arrays and generics don't work terribly nicely... more 5/7/2015 9:17:17 AM
the creation of an object is far less expensive (in terms of time) if the members are not final. No, that's absolutely not the case. Basically, your approach to benchmarking is broken: You're using System.currentTimeMillis() which... more 5/7/2015 9:01:36 AM
Is it possible that myValueAsDecimal has 0,203 after TryParse No. It's just a number - it has no concept of a text format. To think about it another way with a simpler type, consider these two lines of code: int x = 0x100; int y =... more 5/7/2015 8:18:43 AM
In general, don't reinvent the wheel: use base64. That's the general "shorter than hex, but still printable ASCII" solution. There are various base64 options available, depending on which version of Java you're using etc. If there's... more 5/7/2015 6:12:28 AM
I'm not sure whether it's really the best approach, but you could make it a static variable - it's fine to access static variables from instance methods (your tests) after all. Note that this could cause problems if you try to run your... more 5/6/2015 6:27:18 PM
I would create an array instead of a HashMap, given that you know exactly how many counts you need to keep track of: int[] counts = new int[256]; for (byte b : data) { counts[b & 0xff]++; } That way: You never need to do any... more 5/6/2015 5:28:42 PM
What do you actually want to do if this.SelectRowIndexes is null? Currently you're just unconditionally calling Add on it, because both branches of your if statement do the same thing. Note that it definitely wouldn't be null if you'd... more 5/6/2015 4:21:20 PM