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

Leave A Reply

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

You May Also Like

In this post, you’ll learn about the error message “WorkbookNotSupported – The file you selected cannot be opened because it...
  • .NET
  • December 17, 2022
In this post, you’ll learn about the error message “SpecifiedRangeNotFound – The requested range does not exist in the sheet.”...
  • .NET
  • December 17, 2022
In this post, you’ll learn about the error message “SheetRangeMismatch – The sheet provided as the sheet argument is not...
  • .NET
  • December 17, 2022