Browsing 7239 questions and answers with Jon Skeet
Look at your code in the problematic area: private void move(){ if(!instance.getStage().isCollided(hitbox)){ directionY = 1; } else { directionY = 0; hitbox.x += directionX; hitbox.y += directionY; ... more 10/30/2014 10:41:25 PM
You're trying to use generic contravariance for this (if a comparer can compare two TRoom values, it should be able to compare two IRoom values), which would usually be fine - but only when TRoom is known to be a class type. You can fix... more 10/30/2014 10:12:21 PM
Your current approach is effectively treating the three values as a 24-bit number - effectively 0x313239. It sounds like you should be converting it into a string, then parsing that: String text = new String(b_array,... more 10/30/2014 8:13:50 PM
I'd use something like: var lookups = initial.ToLookup(x => ValidateFormat(x.Item1), x => x.Item2); var match = lookups[true].ToList(); var notMatch = lookups[false].ToList(); That checks each item once, splitting the collection... more 10/30/2014 5:59:55 PM
However after searching I couldn't find any explanation as to why %X would return 123. It's just printing the hex representation of the number. Hex 123 = decimal 291. From a printf man page (the first I happened to find): o, u, x,... more 10/30/2014 5:54:58 PM
The Color fields are already of type Color - you don't need to call the Color constructor. The compiler is complaining because there isn't a Color constructor which takes a Color parameter. I suggest you use the more conventionally-named... more 10/30/2014 5:43:50 PM
I haven't tried it, but I'd expect it to be fine if you specify the formatting in the settings: public static void SerializeToStream(MyObject obj, Stream stream) { var settings = GetJsonSerializerSettings(); settings.Formatting =... more 10/30/2014 5:39:24 PM
This is the problem: int j = random.nextInt(); char symbol = "abcdefghijklmnopqrstuvwxyz".charAt(j); The charAt method requires that its argument is within the bounds of the string - you're just using a random integer from... more 10/30/2014 5:30:09 PM
The simplest approach is just to use Max: var max = dictionary.Where(x => x.Value == 3).Max(x => x.Key); If you want to get more than just the highest key, you'd use something like: var topTwo = dictionary.Where(x => x.Value... more 10/30/2014 4:12:39 PM
You need to understand that Java properties files are just lists of key/value pairs. How you interpret those values is up to you. So you should expect that properties.getProperty("file1") will give you the string "./File1"... but you can... more 10/30/2014 3:49:51 PM