what is the difference between internal and private

10,745

Solution 1

An internal method can be accessed from any type (or function) in the same .NET assembly.
A private method can be accessed only 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

Solution 2

internal is the same as public, except that it is only visible inside the assembly it is delcared in. Private is only visible inside the declaring type.

Share:
10,745
Frames Catherine White
Author by

Frames Catherine White

(aka oxinabox) she/her/hers. Research Software Engineer, Invenia Labs. PhD, in Natural Language Processing / Machine Learning. Writes a lot of JuliaLang code.

Updated on June 04, 2022

Comments

  • Frames Catherine White
    Frames Catherine White almost 2 years

    In F# what is the difference between an internal method and a private method.

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