Let say I have this interface in C# and want to implement it in F#
public interface IBatch
{
System.Data.IDbConnection Connection { get; set; }
}
I wish to implement the interface in F# but cant figure out the correct syntax. I have something like this:
type public Batch =
interface IBatch with
member f.Connection
with get() = new Devart.Data.Oracle.OracleConnection()
and set value = ()
The error I'm getting is:
This expression was expected to have type IDbConnection but here has type Devart.Data.Oracle.OracleConnection
F# does not implement implicit downcasting like C# does, you need to have
type public Batch =
interface IBatch with
member f.Connection
with get() = new Devart.Data.Oracle.OracleConnection() :> System.Data.IDbConnection
and set value = ()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.