Browsing 7239 questions and answers with Jon Skeet
Well, there are various options here. You could change the property type to one which only provides a read-only interface (e.g. IReadOnlyList<T> or IEnumerable<T>. That doesn't stop the caller from casting the returned... more 7/18/2015 10:01:44 AM
The anonymous inner class will have a reference to the Foo, as that's how it is about to access thing. It's as if you had: public class FooRunnable implements Runnable { private final Foo foo; public FooRunnable(Foo foo) { ... more 7/17/2015 7:16:08 PM
It doesn't sound like you really need a lambda expression here. You can build a function to return a constant value very easily using expression trees: var expression = Expression.Constant(obj, type); var delegateType =... more 7/17/2015 5:22:57 PM
Is it possible to set the value of this readonly property using reflection? No. Those properties are backed by read-only fields. There is no setter; any assignments performed in the constructor write directly to the fields. If your... more 7/17/2015 5:00:09 PM
You're flushing the MemoryStream, but not the StreamWriter. It's possible that that's buffering. Call sb.Flush() instead of stream.Flush(). (Flushing a MemoryStream doesn't do anything anyway.) Also note that you can use... more 7/17/2015 4:39:52 PM
From what I understand, "timestamp with time zone" is a misnomer anyway - it's just "you supply a time zone with a local value, PostgreSQL will store UTC"... in other words, it's really an extra conversion rather than storing more... more 7/17/2015 2:10:09 PM
Is it just more precise than milliseconds? Yes, it's microseconds in this case. ISO-8601 doesn't actually specify a maximum precision. It states: If necessary for a particular application a decimal fraction of hour, minute or... more 7/17/2015 1:51:52 PM
Does the JAR entry point actually have to be inside the JAR? No, it doesn't. It's entirely reasonable to put the launcher into a separate jar file, and so long as that's in the classpath specified by the manifest, it should be fine.... more 7/17/2015 10:02:17 AM
Use C# 6 and the nameof feature: OnPropertyChange(nameof(IsBarNull)); That generates equivalent code to: OnPropertyChange("IsBarNull"); ... but without the fragility. If you're stuck on earlier versions of C#, you can use expression... more 7/17/2015 9:16:05 AM
It's available even without the class being initialized! Basically, everywhere the constant is used, the compiler will inline the value. For example: public class Constants { public const int Foo = 10; static Constants() { ... more 7/17/2015 8:44:21 AM