What is the difference between internal and private

In F #, what's the difference between an internal method and a private method.

I have a feeling that they are implemented the same way, but mean something else.

+3
source share
3 answers

A method internalcan be accessed from any type (or function) in the same .NET assembly.
Access to a method privatecan only be obtained from the type where it was declared.

Here is a simple snippet that shows the difference:

type A() = 
  member internal x.Foo = 1

type B() = 
  member private x.Foo = 1

let a = A()
let b = B()
a.Foo // Works fine (we're in the same project)
b.Foo // Error FS0491: 'Foo' is not defined
+7
source

internal is the same as public, except that it is visible only inside the assembly into which it is shared. Private view only inside ad type.

+2
source

, "" .

0
source

All Articles