如何确定 Type 值的大小?
let typ = if true then (123).GetType() else "asdf".GetType();;
let sz = sizeof<typ>
let sz = sizeof<typ>;;
----------------^^^
error FS0039
Run Code Online (Sandbox Code Playgroud)
一种解决方案是使用 Marshal.SizeOf(obj),但可能存在另一种解决方案?
这将获取类型变量的大小:
sizeof<System.Type>
Run Code Online (Sandbox Code Playgroud)
提示是里面的任何东西都< ... >需要是类型,而不是变量。