.net - How to seal an overridden property -


suppose have pair of contrived c# classes this:

public abstract class foo {     public abstract int[] legalvalues { get; }     public virtual bool isvaluelegal(int val) {         return array.indexof(legalvalues, val) >= 0;     } } 

and this:

public class bar : foo {     static int[] _legalvalues = new int[] { 0, 1 }; // whatever     public sealed override int[] legalvalues          { { return _legalvalues; } }     public sealed override bool isvaluelegal(int val)         { return base.isvaluelegal(val); } } 

how do in f#? obvious code properties:

[<sealed>] override this.legalvalues get() = // ...  [<sealed>] override this.isvaluelegal value = // ... 

triggers error because sealedattribute apparently can't applied members. can, of course, seal entire class , thereby seal members, (and really important but) have goal of matching existing class signature exactly , base class has other virtual/abstract members should, ideally, remain overridable.

there several limitations f#'s support oo, should not expect able produce f# class hierarchy identical arbitrary c# class hierarchy. far know, there no way override , seal virtual method.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -