F# 名称空间中类的可见性

F# 名称空间中类的可见性,f#,F#,为什么条形图在Foo中不可见?F#声明是自上而下处理的,因此条形图在Foo中引用时未定义。您需要将Bar的定义移动到Foo上方 如果您的类型是相互依赖的,那么您可以使用和来声明它们 namespace Test type Foo() = member this.HelloFoo = "Foo" member this.HelloFooBar = let b = new Bar() // Why is Bar not visible here?

为什么条形图在Foo中不可见?

F#声明是自上而下处理的,因此
条形图在
Foo
中引用时未定义。您需要将
Bar
的定义移动到
Foo
上方

如果您的类型是相互依赖的,那么您可以使用
来声明它们

namespace Test

type Foo() =
    member this.HelloFoo = "Foo"
    member this.HelloFooBar = 
        let b = new Bar() // Why is Bar not visible here?
        this.HelloFoo + b.HelloBar 
type Bar() =
    member this.HelloBar = "Bar"
F#声明是自上而下处理的,因此未在
Foo
中引用的点定义
Bar
。您需要将
Bar
的定义移动到
Foo
上方

如果您的类型是相互依赖的,那么您可以使用
来声明它们

namespace Test

type Foo() =
    member this.HelloFoo = "Foo"
    member this.HelloFooBar = 
        let b = new Bar() // Why is Bar not visible here?
        this.HelloFoo + b.HelloBar 
type Bar() =
    member this.HelloBar = "Bar"