The difference between the two syntaxes

type IFooable =
  abstract Foo : int -> int

type IFooable2 =
  abstract Foo : a : int -> int

type MyClass() =
    interface IFooable2 with
        member this.Foo(b) = 7

What is the difference between IFooable and IFooable2? Are they equivalent? What is the purpose of this in my example? When to use it?

+3
source share
1 answer

IFooable2 names its parameter; IFooable does not.

It matters when systems reflect parameter names. As an example, when you use WCF with an interface type marked with ServiceContractAttribute, by default WCF uses the parameter names in the interface to control the names that appear in the XML data projection onto the wire.

It is also important for a snap, for example, to reference this F # code in C #, declare a variable of each type, and view intellisense hints for each method.

( ).

+4

Source: https://habr.com/ru/post/1722051/


All Articles