模块ExchangeSocket =
type Socket(url, id, key) =
let Communicator = new TestCommunicator(url)
let Client = new WebsocketClient(Communicator)
do
Communicator.Name <- "test"
Communicator.ReconnectTimeoutMs <- int (TimeSpan.FromSeconds(30.).TotalMilliseconds)
如果我们看最后两行,则C#用法如下:
Communicator = new WebsocketCommunicator(wsUrl) { Name = "tst", ReconnectTimeoutMs = (int) TimeSpan.FromSeconds(30).TotalMilliseconds };
现在,我读到要创建一个类构造函数,我必须使用'new'关键字;因此,我使字段成为成员并执行“新”部分:
member this.communicator : TestCommunicator
member this.client : WebsocketClient
new() =
this.communicator <- new TestCommunicator(url)
this.client <- new WebsocketClient(this.communicator)
但是这不起作用(在此示例中,第15行是第一行)
Socket.fs(15,64):[FS0010]成员定义中此刻或之前的不完整结构化构造。预期为“ with”,“ =”或其他标记。我的问题是: