Accessing a namespace containing .base in its name from F#

梦想的初衷 提交于 2019-12-10 15:29:28

问题


As the title says, I'm trying to use a class declared in a namespace which contains "base" in its name. Think of a situation like the following:

open Foo.base.Bar

In C# I'd just use @ before base but F# seems to ignore that and to think that @ is the infix operator used for list concatenation. Since the namespace belongs to a third-party library which I cannot modify, is there a way I can still access it from F#?


回答1:


In F#, you can achieve similar thing by enclosing the special name between two pairs of `` symbols. The following should do the trick:

open Foo.``base``.Bar

This is a bit more flexible than in C# - the name can contain almost anything, so you can for example define members with space in the name:

let ``some name!`` = 42


来源:https://stackoverflow.com/questions/2754970/accessing-a-namespace-containing-base-in-its-name-from-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!