in C# it is possible to apply an attribute to the return of a method:
[return: DynamicAttribute]
public object Xyz() {
return new ExpandoObject();
}
Is this possible in F#?
Background :
I would like a method of a library written in F# which will be consumed in a language like C# to return "dynamic" from a method. If I look into a similarly defined method compiled from C# it seems like the return type is object and the DynamicAttribute is applied to the return value of the object.
Sure, you can apply a similar attribute target for the return value.
let SomeFunc x : [<return: SomeAttribute>] SomeType =
SomeOperation x
See the table of how to specify attribute targets at the end of this MSDN page .
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.