The F# unbox
function is pretty much just doing cast to any other type that you specify. In C#, this could be written like this:
static R Unbox<R>(object anything) {
return (R)anything;
}
So in your case with double[,]
you'd need something like:
var array = (double[,])boxed;
In most cases unbox<'R> anything
would just translate to casting using (R)anything
. The only case where this does not work is when you are in another generic method and you are casting between two generic types. In that case, you need to go to object
first (to make sure that the value is boxed):
static R Unbox<R, T>(T anything) {
return (R)(object)anything;
}