For what it's worth, it's hard for me to understand your distinction
between "doing this at runtime" and "at compile time". In particular,
while the code is written before "compile time", none of the code executes
until "runtime".
From your elaboration, I gather that what you really mean is that you
don't actually have even a type parameter T to work with (again, some
actual sample code would have been helpful in expressing the question).
With that in mind...
I have no idea. We still don't really know what you're doing. Your
question was presented as if it was in the context of a generic type or
method, but now I'm not so sure.
The code you posted certainly _could_ do what you want. But it would box
the value type as returned. That's not exactly the same as what
"default(T)" would return. But if the code accomplishes your goal, that
seems to me to be the same as "would work". Right?