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 quickly remove multiple line breaks in Excel using VBA code?
There are times when you might copy few data from different source and you would end up getting unne...
How to change orientation of the worksheets in Microsoft Excel ?
This blog post will show the steps that are needed to change the orientation of the current workshee...
How to hide page breaks in worksheets in Microsoft Excel ?
When the page breaks is used to adjust the print area in a worksheet in excel , this would show up a...