1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
type Foo<'T>() =
    static let mutable count = 0
    do
        count <- count + 1
    static member NumInstances = count
 
let Main() =
    let i1 = new Foo<int>()
    let i2 = new Foo<int>()
    let i3 = new Foo<int>()
    let s1 = new Foo<string>()
    printfn "int: %d   string: %d   bool: %d" 
                    (Foo<int>.NumInstances)
                    (Foo<string>.NumInstances)
                    (Foo<bool>.NumInstances)
 
Main()
By on 11/23/2010 2:03 PM ()

Thank you, Brian. I've missed that it requires primary constructor.

By on 11/29/2010 11:19 AM ()

Not stated explicitly above - but this is standard .NET behavior and not F# specific.

By on 11/23/2010 7:49 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper