You don't have to use the typeof - function at all - just do something like

1
2
3
4
5
6
7
8
9
10
11
 

let test (t : obj) = 

   match t with

   | :? int -> () // ... its an integer 

   | :? string -> () // ... its an string 

   | _ -> () // ... whatever 
By on 2/3/2009 4:48 AM ()

To preempt a possible next question, you can bind to a variable like so:

1
2
3
4
5
let test (t : obj) = 
   match t with
   | :? int as x -> () // ... x is an integer 
   | :? string as x -> () // ... x is a string 
   | _ -> () // ... whatever
By on 2/3/2009 5:15 AM ()
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