Here is my serializable abstract class
namespace NEN_FS {
[Serializable()]
abstract public class NFS : IEquatable<NFS> {
abstract public string Path { get; set; }
public NFS() {
Path = "";
}
public NFS(string path) {
Path = path;
}
public override bool Equals(object obj) {
NFS other = obj as NFS;
return (other != null) && ((IEquatable<NFS>)this).Equals(other);
}
bool IEquatable<NFS>.Equals(NFS other) {
return Path.Equals(other.Path);
}
public override int GetHashCode() {
return Path != null ? Path.GetHashCode() : base.GetHashCode();
}
}
}
What I have in F#: let file = files.[0]. and there is no Path field.
Why is that? How can I access Path property?
Huh? Strange.. maybe some bug in meta-data reading or intellisense. Try writing file.[0].Path and compiling. Sometimes the Intellisense skips something but the compiler sees whole structure right and compiles without complaints.
If not working – then maybe F# doesn’t like
abstractfor some reasons unknown to me (i.e. some overall nonsense like im-possibility of instantiating an ‘example object’).. I’m not fluent in F# yet, but thinking about .Net itself, have you tried to define and use an interface instead of abstract base? I mean:And then expose
IEnumerable<INFS> Filesinstead ofIEnumerable<NFS> Files. That way it just have to work, because interfaces are the core of access to many things..