Javatpoint Logo
Javatpoint Logo

F# Access Control

Access control specifies the accessibility of code. By using these you can specify the scope of data, method, class etc.

There are 3 types of access control in F#:

  1. Public or Default
  2. Private
  3. Internal

F# Public Access Control Example

Public access control also known as default. It is accessible for all. If you don't specify any access control explicitly in your code, by default it follows public access control.


This is public method
a = 10

F# Private Access Control Example

Private access control is most restricted and has limited scope. F# provides private keyword to declare private members in the class or type. The scope of private is limited to the local block in which it is declared.


error FS0491: The member or object constructor 'display' is not accessible. 
Private members may only be accessed from within the declaring type.

F# Internal Access Control

Internal access control is only accessible from the same assembly. An assembly is a file which is automatically generated by your compiler after compilation of F# code. It can be either Dynamic Link Library (DLL) or Executable File (exe).


This is internal method
a= 10

Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials

B.Tech / MCA