Browsing 7239 questions and answers with Jon Skeet
I suspect the problem is that it's using Enumerable.Contains(string, char) (because string implements IEnumerable<char>) whereas you really want string.Contains(string). Just changing it... more 3/17/2014 3:57:50 PM
Casting doesn't change the object at all. The result is just a reference to the same object, but with a different compile-time type. Casting to a super-type can't fail, it can only make a difference to the compile-time type of the... more 3/17/2014 1:53:28 PM
You're recursing unconditionally: public String getHex(String binary) { StringBuilder hexBuilder = new StringBuilder(); int startIndex = 0; int endIndex = 4; while(true) { ... more 3/17/2014 10:16:58 AM
No, I wouldn't do this everywhere in your source code. Firstly, I'd use a dedicated logging package which may have cunning ways of doing a better job, and will certainly be less obtrusive in your source code. There are various options... more 3/17/2014 8:59:42 AM
I think you've misunderstood both static and volatile. static is just about having a single field across the whole type. It has nothing to do with threads - it's just about whether there's one field for the type (static) or one field for... more 3/17/2014 6:49:01 AM
You're currently using Remove (which takes an individual item to remove) instead of RemoveAll (which takes a predicate). However, a better approach might be to create a set of all IDs you want to remove, and then use a single call to... more 3/17/2014 6:43:13 AM
Get rid of the check for c1 being null - that's provably impossible. A constructor can never return null. You may want to test that your constructor doesn't throw an exception - in which case just: public void testCaesarCipher() { ... more 3/16/2014 9:36:53 PM
It's entirely valid for a class not to have a main method - or for it to have a main method which isn't declared as public static void main(String[] args). However, in order to treat a class as the entry point for a Java application, it... more 3/16/2014 5:51:09 PM
ForEach simply isn't intended to do this - just like you wouldn't be able to do this with a foreach loop. Personally I'd just use a for loop - it's easy to read and clear: for (int i = 0; i < array.Length; i++) { // Alternatively,... more 3/16/2014 9:14:02 AM
If you could actually keep one of them as an ISet<T>, you can just call SetEquals. You could do this optionally, of course: ISet<Foo> setFoo = theirs as ISet<Foo>; if (setFoo != null && theirs.SetEquals(mine)) { ... more 3/16/2014 8:17:14 AM