Browsing 7239 questions and answers with Jon Skeet
Just add the 0x part yourself in the format string: // Local variable names to match normal conventions. // Although Color doesn't have ToRgb, we can just mask off the top 8 bits, // leaving RGB in the bottom 24 bits. int colorValue =... more 10/2/2014 12:12:32 PM
For expressions like this: (Employer)obj.getEmployeeSSN() The . has higher precedence - "binds tighter" - than the cast. So it's closer to: (Employer) (obj.getEmployeeSSN()) ... whereas you want: ((Employer)... more 10/1/2014 8:54:22 PM
Why double dispatch via "dynamic overload" based on argument type isn't natively supported by C#? It is, via dynamic typing: static void Main(string[] args) { var objs = new object[] { new Class1(), new Class2() }; // Note... more 10/1/2014 8:17:28 PM
Assuming you don't put any other declarations or using directives in the Outer namespace, there's no difference at all. Given that you would very very rarely declare members in multiple namespaces within a single file, I'd suggest using... more 10/1/2014 8:09:49 PM
If I have class like this, which is essentially just a package object, is it breaking standards to have it follow the package naming conventions? Yes. It's not a package, it's a class, so it should follow class naming conventions...... more 10/1/2014 6:25:25 PM
Currently you're adding multiple elements directly to the document - so you'd end up with either no root elements (if the dictionary is empty) or potentially multiple root elements (if there's more than one entry in the dictionary). You... more 10/1/2014 4:11:10 PM
You're in a loop: You're sleeping Being interrupted and printing the stack trace Going back to sleep Never being interrupted again So it is "coming out of sleep state" (otherwise you wouldn't see the stack trace) - but you're then... more 10/1/2014 3:14:49 PM
The problem is your use of Scanner.next(): Finds and returns the next complete token from this scanner. A complete token is preceded and followed by input that matches the delimiter pattern. The default delimiter for Scanner is... more 10/1/2014 3:04:23 PM
If you only need to support a very specific set of types that are supported by it, then Convert.ChangeType may be okay: object value = (string) ds.Tables[0].Rows[0]["MyVarcharColumn"]; return (T) Convert.ChangeType(value,... more 10/1/2014 2:42:17 PM
No, your string is actually UTF-16-encoded - it's a Java string, and Java strings are sequences of UTF-16 code units. It (mostly) doesn't matter how SQL server stores the value internally, so long as it can represent the same character... more 10/1/2014 2:09:36 PM