Browsing 7239 questions and answers with Jon Skeet
No, operators can't be generic in C#. You can overload operators within generic types, but the operators themselves can't have type parameters. If you look at the syntax for user-defined operators in the C# spec (e.g. in section 10.10 of... more 7/21/2014 6:18:11 AM
Absolutely - you just need to cast the null value to the right type so that the compiler knows which type you want for that property. For example: return Ok(new { Answer = (string) null, Text = ..., ... }); more 7/20/2014 3:22:57 PM
I wouldn't use Activator.CreateInstance for this. I'd use Type.GetConstructors() to get all the constructors, and then find one which has the same number of parameters as the anonymous type has properties, and with the same names. If there... more 7/20/2014 3:16:20 PM
Well, here's a non-regex approach: public IEnumerable<List<string>> ReadSeparatedLines(string file) { List<string> lines = new List<string>(); foreach (var line in File.ReadLines(file)) { if... more 7/20/2014 8:42:05 AM
This is the problem in Stack<E>: private Node head; and likewise later: Node nodeToBePopped; And in Node<E> itself: Node next; You're using the raw type Node here, so all the generics are lost, effectively. See the... more 7/20/2014 8:26:45 AM
You've got the command line round the wrong way. You want: java fib or preferably follow Java naming conventions, calling your class Fib rather than fib, and use java Fib (Even better, use packages - but that's probably the next... more 7/19/2014 10:13:12 AM
Noda Time deliberately ships with an internal copy of the R# annotations, so that those who do want them can benefit from them - it will know which methods are pure, etc. It sounds like you don't actually want to use annotations at all,... more 7/18/2014 11:17:59 PM
The node type for not isn't for !(expression) it's just for !expression - the parentheses aren't part of it. Parentheses are necessary in source code to indicate the precedence you want. They're not necessary in expression trees because... more 7/18/2014 7:28:22 PM
They're created by the compiler. You can see them by just compiling some code and looking at what you get on disk. You'll end up with things like Foo$1.class where Foo is the class that contains the anonymous method. For example: public... more 7/18/2014 6:33:32 AM
Firstly, it's important to be able to diagnose this yourself more. Either adding some logging or using a debugger should help you work out what the code is doing - you shouldn't just need to depend on perfect output. Secondly, some unit... more 7/18/2014 5:32:42 AM