开发者

F#: Implementing interface with function name the same as the keyword begin

开发者 https://www.devze.com 2023-01-18 15:59 出处:网络
I am trying to implement the IVector interf开发者_JAVA百科ace which is part of the Microsoft.VisualC.StlClr namespace.It has a member function begin().If I try to implement the interface then it compl

I am trying to implement the IVector interf开发者_JAVA百科ace which is part of the Microsoft.VisualC.StlClr namespace. It has a member function begin(). If I try to implement the interface then it complains about "unexpected keyword 'begin' in object expression".

Is this because begin is a keyword and I can't implement a member function with that name?

B.


you can try to wrap it into backticks. IVector inteface is too big to implement it as sample, so example will be smaller - the code below compiles without any errors.

// C#
public interface ITest
{
    void begin();
}

// F#
type Test() = 
    interface UStatic.ITest with
        member this.``begin``() = ()
0

精彩评论

暂无评论...
验证码 换一张
取 消