Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这个 C# 的 F# 等价物是什么:
public T GetNewItem() { return new T(); }
此外,您如何将新的 T()作为 ref 单元返回,以便在需要 out 或 ref 参数的 .Net 库中使用?
我认为像这样简单的事情会起作用:
let getNewItem() = new 'T()
它推断出默认的构造函数约束。
let mutable d = getNewItem() //d inferred to be System.DateTime DateTime.TryParse("1/1/2011", &d)