Browsing 7239 questions and answers with Jon Skeet
The superscript part isn't the first tricky part here - although it's not clear how you'd want that to be represented anyway (HTML with <sup> tags? something else?) The first tricky part is knowing how to get the ordinal (st, nd,... more 10/13/2014 10:34:23 AM
To start with, you've got a lot of string operations here - you're creating lots of new strings by removing a single character each time, and you're using IndexOf a lot too. I would start very simply - just sort the characters in each... more 10/13/2014 8:05:43 AM
You're currently returning a sequence of anonymous type objects. That sequence can't be cast to a List<T> because it isn't a List<T>. You could change the declaration to: IEnumerable<dynamic>... more 10/13/2014 6:20:13 AM
You're calling input.next() far too often here: if (input.next().equals("P")) { ... } else if(input.next().equals("R")) { ... } else if(input.next().equals("S")) { ... } ... By the time it's checked for S, it's read three... more 10/13/2014 6:16:49 AM
The code within Mammals has access to protected members of Animals, but only via an expression of type Mammals or a subtype. From outside the class - which I assume this is - there's no access to protected members. From section 3.5.3 of... more 10/13/2014 6:03:08 AM
An object doesn't have a name. A variable has a name, but multiple variables could have values which refer to the same object. For example: Beast monkey = new Beast(); Beast donkey = monkey; Now they both refer to the same object - so... more 10/12/2014 7:25:50 PM
Just avoid examining the connection object after you've disposed of it. ("Doctor, it hurts when I do this..." "Stop doing that then!") The easiest - and most reliable - way to do that is to use a using statement instead: using (var conn =... more 10/12/2014 7:20:58 PM
Deferred/immediate execution isn't relevant here. If you called ToList(), that wouldn't change anything. There are two options to make this simpler though. Firstly, if you don't need it to be the exact Dog type, but DogBeagle or anything... more 10/12/2014 1:57:52 PM
You basically don't need to do anything except stop thinking about bytes as numbers. Think of them as 8 bits, and Java and C# are identical. It's rare that you really want to consider a byte as a magnitude - it's usually just binary data... more 10/11/2014 8:29:33 PM
As far as I know the JVM doesn't guarantee that the array will be stored contiguously. While I don't see any cast-iron guarantee that the array elements will be stored contiguously, I believe they will for every mainstream... more 10/11/2014 7:54:27 AM