Visual Studio 2010 includes a new programming language, F#. To create a new console application
- On the File menu, point to New, and then click Project.
- If you cannot see Visual F# in the Templates Categories pane, click Other Languages, and then click Visual F#. The Templates pane in the center lists the F# templates.
- Look at the top of the Templates pane to make sure that .NET Framework 4 appears in the Target Framework box.
- Click F# Application in the list of templates.
- Type a name for your project in the Name field.
- Click OK.
- The new project appears in Solution Explorer.
First F# program holds integer (its square) and string value and then print them later.
open System
let iNum = 5
let strMsg = "Hello"
let iSquare = iNum * iNum
System.Console.WriteLine(iNum )
System.Console.WriteLine(aString)
System.Console.WriteLine(iSquare)
Like other .NET languages, press CTRL+F5 to run the code. A Command Prompt window appears that contains the following values.
Otherwise, you can execute F# program using Interactive window. First, select the let expressions in the previous procedure. Then, right-click the selected area and then click Send to Interactive. Alternatively, press ALT+ENTER.
The F# Interactive window opens and the results of interpreting the let expressions are displayed.
No comments:
Post a Comment