F# Inherit from C# class + access protected fields

后端 未结 2 947
轻奢々
轻奢々 2021-01-21 08:02

I have this base class that creates a new SQL Server connection and does some utility methods in C#, I want to inherit in F#. Currently I cannot access the protected fields in t

2条回答
  •  被撕碎了的回忆
    2021-01-21 08:51

    You can add a self-identifier to the constructor:

    type Transfer ( server : string, db : string ) as this = 
      inherit SQL(server, db)  
      let accessAbstractConn = this.conn
    

    or, use the base keyword:

    type Transfer ( server : string, db : string ) = 
      inherit SQL(server, db)  
      let accessAbstractConn = base.conn
    

提交回复
热议问题