Using the framework from F#

Just by typing the open statement, you can use the .NET Framework, or any other referenced libraries. To access the Console type, just add the following line to your source code:

open System

This program uses the built-in library function printfn, and then the WriteLine function to write “Hello world” to the screen.

printfn "Hello world"
open System
Console.WriteLine("Hello world")

So, displaying a message box, is just a matter of adding a reference to System.Windows.Forms, and this is how it could be done:

let x=System.Windows.Forms.MessageBox.Show("Hello world")

Or like so:

open System.Windows
let y=Forms.MessageBox.Show("Hello world")

Or even:

open System.Windows.Forms
let z=MessageBox.Show("Hello world")

Bjud mig på en kopp kaffe (20:-) som tack för bra innehåll:

Bjud mig på en kopp kaffe (20:-) som tack för bra innehåll!

Comments

Important information: If you have not commented before, your comment will be reviewed before it is published. This means that you will not see it immediately, but I have received it. This is not because I want to filter comments, but because I want to prevent spam and advertising.

Leave a Reply

Your email address will not be published. Required fields are marked *