如何在f#上创建XNamespace ?

时间:2022-03-22 13:57:57

C# Sample:

c#示例:

XNamespace aw = "http://www.adventure-works.com";

How does F # I write?

我怎么写?

I try that:

我试一下:

let ns : XNamespace = "URI ADDRESS";;

F# Say Error

f#说错误

2 个解决方案

#1


12  

F# doesn't have implicit operators, so:

f#没有隐式运算符,所以:

let ns = XNamespace.op_Implicit "http://www.adventure-works.com"

If you use this a lot, you might want to put it in a function or operator to hide the ugliness a bit, e.g:

如果你经常使用它,你可能想把它放到函数或运算符中,以隐藏一些丑陋的地方,例如:

let inline xns n = XNamespace.op_Implicit n
let ns = xns "http://www.adventure-works.com"

#2


11  

F# doesn't have implicit operators, but you can use the Get() method:

f#没有隐式运算符,但是可以使用Get()方法:

let ns = XNamespace.Get "URI ADDRESS"

#1


12  

F# doesn't have implicit operators, so:

f#没有隐式运算符,所以:

let ns = XNamespace.op_Implicit "http://www.adventure-works.com"

If you use this a lot, you might want to put it in a function or operator to hide the ugliness a bit, e.g:

如果你经常使用它,你可能想把它放到函数或运算符中,以隐藏一些丑陋的地方,例如:

let inline xns n = XNamespace.op_Implicit n
let ns = xns "http://www.adventure-works.com"

#2


11  

F# doesn't have implicit operators, but you can use the Get() method:

f#没有隐式运算符,但是可以使用Get()方法:

let ns = XNamespace.Get "URI ADDRESS"