Declaring Variables in F#

To learn any new programming language , it is necessary to learn the basics first which includes how to declare and define basic data types .

Below is a sample code snippet demonstrating how to declare some of the basic data type variables in F#

Declaring Variables in F#

open System
[<EntryPoint>]
let main argv = 
    // Integer Variable
    let inti = 7
    // Unsigned Integer
    let unsignedi = 7u
    // Declare Decimal
    let decimali = 1M
    // declare Short
    let shorti = 7s
    // declare Long
    let longi = 5L
    // declare byte
    let bytei = 7y
    // declare bool
    let booli = true
    //declare double
    let doublei = 0.7
    //declare float
    let floati = 10.6F
    // declare character
    let chari = 'G'
    //declare string
    let stringi = "Ginktage.com - Programming and F# Website"
    Console.WriteLine(inti)
    Console.WriteLine(unsignedi)
    Console.WriteLine(decimali)
    Console.WriteLine(shorti)
    Console.WriteLine(longi)
    Console.WriteLine(bytei)
    Console.WriteLine(booli)
    Console.WriteLine(doublei)
    Console.WriteLine(floati)
    Console.WriteLine(chari)
    Console.WriteLine(stringi)

    let retval = Console.ReadLine()
    0 // return an integer exit code

image

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Reply


x

Interesting BlogPosts to read

How to insert bullets in to cells in Microsoft Excel ?
Do you want to insert bullets in cells of Microsoft Excel?. Here's how you can do it. How to insert ...
How to resize print area and fit to Single page in Excel 2016 ?
When you try to print a worksheet in Microsoft Excel 2016 , you may notice that the content might ov...
How to find the Created and Last Modified time in Microsoft Excel ?
You can easily find out the exact date and time when the excel workbook was created and modified usi...