Browsing 7239 questions and answers with Jon Skeet
Can I make sure that in dictionary in C# there will be only a single of a specific value in it? Not as such (it wouldn't follow the the normal dictionary contract at that point), but it sounds like you effectively want a... more 3/3/2014 7:59:46 PM
Well they may well be executed in different threads, for one thing. If IsDoingLongRunningWork affects a user interface (for example) then it should probably only be changed in the UI thread, in which case the first code is incorrect (the... more 3/3/2014 3:08:27 PM
The first answer I gave missed some points, but this should do it: Dim o As Object = If(myBool, 5, DirectCast(Nullable.GetUnderlyingType(GetType(Integer)), Object)) This uses the fact that Nullable.GetUnderlyingType will return a null... more 3/3/2014 1:17:55 PM
Looking at the docs, I suspect you want AsString instead of ToString(). That would call CodeTypeRef.AsString: AsString return a string representation for the CodeTypeRef in the language being modeled. For example, if the vsCMTypeRef... more 3/3/2014 7:23:00 AM
I would strongly suggest not using the built-in binary serialization even if you could... and it sounds like basically can't anyway. There are plenty of alternatives for serialization, depending on your requirements. You could... more 3/3/2014 6:47:53 AM
After doing a bit of research, it looks like you're missing the eventbus jar file. You can download the jar file from the Maven repository. Note that I didn't know anything about this class beforehand - it was merely a matter of looking... more 3/2/2014 7:06:12 PM
In C#, you need to specify out and ref modifiers at the call site as well as in the member declaration. That means that anyone reading the code is aware of what is going on. (This is a big boost to readability, in my view.) So you... more 3/2/2014 6:05:04 PM
It's a valid line if args is declared as a String[][] - but that wouldn't be how a main method would be declared. length is a valid member of an array, but it's not a (public) member of the String class. If you're trying to check the... more 3/2/2014 5:32:20 PM
Rather than try to mock a static method here, I would strongly recommend introducing a Clock interface along these lines: public interface Clock { Date now(); // Or long, or Instant if you're using Joda Time } Then you can have a... more 3/2/2014 5:01:27 PM
You're calling ToList for no obvious reason. It would also make things clearer if you moved the query out of the return statement. Breaking your code down, you've effectively got: // We're not certain what type `db.Followusers` is, to be... more 3/1/2014 9:20:58 PM