Browsing 7239 questions and answers with Jon Skeet
The thing to do is take look at the JSON you want. It's an object, with a Product property, which is an array of product objects. So the simplest way to do that is create a class modelling that: public class JsonRoot { ... more 10/10/2016 6:26:08 AM
In both cases, StringBuilder.toString() creates a new string. In the first case, String.intern() finds that there's no string "apple" in the intern pool, so adds the provided one to the pool and returns the same reference - which is why... more 10/8/2016 7:14:47 AM
Each value within TimeUnit overrides it, basically. You never end up calling that implementation, because you never have a reference to an object of type TimeUnit - it's always a subclass representing one of the values. more 10/5/2016 3:50:53 AM
The oddity here is that your class implement IEqualityComparer<CustomClass> instead of IEquatable<CustomClass>. You could pass in another instance of CustomClass which would be used as the comparer, but it would be more... more 10/4/2016 11:54:34 AM
The problem is that you're adding a new entry into the list every time you find an entry which doesn't have the same ID... your add call is inside your loop, and it shouldn't be. Basically, you should have something like: public void... more 10/2/2016 5:43:41 PM
You can't "skip" the comparison. What would you expect the sorting code to do? You've got to provide it with a result. Two options are common: Throw a NullPointerException to indicate that you just don't support comparing null values.... more 10/1/2016 7:45:35 AM
The simplest way is probably to write a method to get the start of a week. Then you can subtract one date from another, divide the number of days by 7 and add 1 (to make it inclusive). Personally I'd use Noda Time for all of this, but... more 9/30/2016 9:49:50 AM
You just write a constructor which is able to provide the name and extensionNumber values to the superclass constructor, and do whatever else you like. I would personally make the Employee constructor protected as well, given that it... more 9/29/2016 7:39:57 AM
Look at this statement: m_safer.DiableCommands += curr.DiableFunctionality(); That's trying to invoke curr.DiableFunctionality and then subscribe the result of the method call to the m_safer.DiableCommands event. You don't want to... more 9/28/2016 8:38:14 AM
If your constraint is that there should be exactly one listingAgent element within each commercial element, that's very simple: var broken = doc.Descendants("commercial") .Any(c => c.Elements("listingAgent").Count() !=... more 9/28/2016 6:16:48 AM