Whats the utility of public constructors in abstract classes in C#?

Absolutely correct. You should favor the protected constructor. EDIT: no the compiler doesn’t complain, but tools like FxCop (& Code Analysis) do. I believe there are some weird reflection tricks you can do with public constructors on abstract classes, but from a standpoint where you are merely providing base class functionality to other developers writing … Read more

AS3 – Abstract Classes

abstract classes are not supported by actionscript 3. see http://joshblog.net/2007/08/19/enforcing-abstract-classes-at-runtime-in-actionscript-3/ the above reference also provides a kind of hackish workaround to create abstract classes in as3. Edit also see http://www.kirupa.com/forum/showpost.php?s=a765fcf791afe46c5cf4c26509925cf7&p=1892533&postcount=70 Edit 2 (In response to comment) Unfortunately, you’re stuck with the runtime error. One alternative would be to have a protected constructor…. except as3 doesn’t … Read more

Interface + Extension (mixin) vs Base Class

Downside of extension methods: clients pre-C#3/VB9 won’t be able to use it as easily. That’s about it as far as I’m concerned – I think the interface-based approach is significantly nicer. You can then mock out your dependencies nicely, and everything is basically less tightly coupled. I’m not a huge fan of class inheritance unless … Read more

What are the differences between extern, abstract, and partial for methods in an abstract class?

extern is unlikely to be something you want to use. It means that the method is implemented, but implemented externally – and typically used in interop scenarios where you’re defining a method implelemented in external code. abstract, on the other hand, means you’re defining the API for the method, but not providing an implementation. The … Read more

abstract explicit interface implementation in C#

Interesting – I’m not sure you can. However, if this is your real code, do you ever want to implement the non-generic GetEnumerator() in any way other than by calling the generic one? I’d do this: abstract class MyList<T> : IEnumerable<T> { public abstract IEnumerator<T> GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } That saves … Read more

tech