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.

Output:

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.

Output:

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).

Output:

This is internal method
a= 10





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA