Browsing 7239 questions and answers with Jon Skeet
You're calling URLEncoder.encode, but ignoring the result. I suspect you were trying to achieve something like this: String encoded = URLEncoder.encode(message, "UTF-8"); URI uri = URI.create(encoded); ... although at that point you'll... more 12/16/2014 8:28:04 AM
If you want to get multiple properties out, you could use multiple parameters, where each extracted a single value, but it would be more common to use a lambda expression which creates an anonymous type. For example: var result =... more 12/16/2014 7:36:04 AM
TL;DR version of this answer: Variables of primitive types never have a different type at execution-time to their compile-time. (A double is always a double, never a float, etc.) Overload resolution (picking which method signature is... more 12/16/2014 7:25:19 AM
I would actually think about readability before performance, unless you know you have a performance issue. But even so, you can definitely improve the code. I would consider using ToDictionary to convert each detail element into a... more 12/15/2014 4:20:56 PM
Well that's just a matter of changing your condition to be "where the extension is any one of a set" and removing the pattern from the GetFiles call. Also note that you don't need to call ToArray() - just iterate over the results: var... more 12/15/2014 4:03:15 PM
The problem is that your type implements IQueryable<>, so the Queryable method is chosen by member lookup - so the compiler tries to create an expression tree from your lambda expression... and that's what fails. The dictionary... more 12/15/2014 3:06:54 PM
UTF-8 is a red herring here. You don't need to convert to UTF-8 and back at all - you just need to fix your strings so that you're not escaping the backslash: SUNDAY(1, "Sunday", "\u0627\u0644\u0623\u062d\u062f"), // etc Within a string... more 12/15/2014 10:39:35 AM
You can write a static constructor with the same syntax as a normal constructor, except with the static modifier (and no access modifiers): public class Foo { static Foo() { // Code here } } Usually you don't need to do... more 12/15/2014 9:47:06 AM
HttpServlet is an abstract class, not an interface - Servlet is an interface, but you rarely implement that directly. Just change this: public class ErpServlet implements HttpServlet { to public class ErpServlet extends HttpServlet {... more 12/15/2014 9:45:13 AM
The .NET types don't give you a decent answer to this without having to write code to try one answer and adjust appropriately, but my Noda Time project is designed to handle this sort of thing. For example: LocalDate x = new... more 12/15/2014 9:33:08 AM