如何将以下函数调用转换为F#call?
Hashtable table = (Hashtable) cookieJar.GetType().InvokeMember("m_domainTable",
BindingFlags.NonPublic |
BindingFlags.GetField |
BindingFlags.Instance,
null,
cookieJar,
new object[] {});
以下转换F#代码在new Object[]
let cs = cc.GetType().InvokeMember("m_domainTable", BindingFlags.NonPublic |||
BindingFlags.GetField |||
BindingFlags.Instance,
null,
cc,
new Object[] {}))
答案 0 :(得分:7)
要在F#中创建一个新的空数组,只需编写[| |]
,因此您的代码应为:
let flags = BindingFlags.NonPublic ||| BindingFlags.GetField ||| BindingFlags.Instance
let cs = cc.GetType().InvokeMember("m_domainTable", flags, null, cc, [| |])