在F#中是否有使用T = XYZ导入指令的C#?

Dav*_*vid 3 f#

在C#中,我可以通过编写为类型定义别名

using Foo = Full.Name.Space.Of.My.TypeWithAVeryLongName;
Run Code Online (Sandbox Code Playgroud)

在代码文件中我可以从那时起引用我的类型Foo而不是TypeWithAVeryLongName并且不需要导入Full.Name.Space.Of.My.

我如何更改open ...F#中的指令以实现类似的功能?

Tay*_*ood 6

您可以声明类型缩写:

type Foo = Full.Name.Space.Of.My.TypeWithAVeryLongName
Run Code Online (Sandbox Code Playgroud)


s95*_*163 5

只是一些附加信息,如果你只想要一个类型的缩写泰勒伍德的答案就是那个.

如果要缩写(或更改)模块名称,可以使用:

module Short = MyVeryLong.Helpers.Container

命名空间定义为的位置

module MyVeryLong.Helpers.Container在另一个地方/文件/ DLL.你可以将你的类型称为Short.MyType.

但这只适用于嵌套在命名空间中的模块.据我所知,你不能缩写纯命名空间名称.