I'm not clear on exactly what you're asking; if you want to get a Type instance for System.Tuple`4[System.Int32,System.Int32,System.Int32,System.Int32], then the easiest way is:

1
typeof<int*int*int*int>

If you know the tuple's size and have Type instances at runtime and want to create a tuple from that, you can do

1
typedefof<_*_*_*_>.MakeGenericType(types)

If you don't know the number of elements or the types until runtime, you can do

1
Microsoft.FSharp.Reflection.FSharpType.MakeTupleType(types)

Does that answer your question?

By on 4/7/2010 3:53 PM ()

yes, thank you!

however, and i just noticed that there is also another way to do it:
the left hand expression must have the same type as right hand expression (of a let), so i can just fetch it over Expr.Type...
So now i am free to switch between

1
Microsoft.FSharp.Reflection.FSharpType.MakeTupleType(types)

and

1
Expr.Type

depending on what performs better...

thanks again

By on 4/8/2010 4:02 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