[英]F# and generic types
Its possible to create this in f#? 它有可能在f#中创建吗?
public TTarget Map<TTarget>(string SQL) where TTarget : new()
{
}
let map<'T when 'T: (new: unit -> 'T)> (sql: string) =
new 'T()
Actually, the constraint is unnecessary. 实际上,约束是不必要的。 This works just as well.
这也适用。
let map (sql: string) = new 'T()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.