Link to Snippet

'use' Bindings

Show's how to use F# 'use' key word to dispose a resource when it passes out of scope.

1: 2: 3: 4: 5: 6: 7: 8: 9: 10:

openSystem.IO// function to read fist line from a fileletreadFirstLinefilename=// open file using a "use" bindingusefile=File.OpenTextfilenamefile.ReadLine()
// call function and print the resultprintfn"First line was: %s" (readFirstLine"mytext.txt")