Created
June 2, 2011 08:12
-
-
Save nagat01/1004102 to your computer and use it in GitHub Desktop.
F# static variable,static constructor,destructor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TODO: Test2's destructor does not work | |
open System | |
open System.IO | |
open System.Net | |
type Test2() = | |
// static variable | |
[<DefaultValue>] | |
static val mutable private i:int | |
// static constructor | |
static do | |
Test2.i <- 4 | |
Console.WriteLine "inside static constructor.." | |
// primary constructor | |
do Console.WriteLine("inside regular constructor..i={0}",Test2.i); | |
// it aimed to behave as destructor but didn't | |
override x.Finalize() = Console.WriteLine "destructor(hopefully) called for each object" | |
Console.WriteLine "Test2" | |
new Test2() |> ignore | |
new Test2() |> ignore | |
Console.ReadKey() |> ignore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment