C#: Variable in einen Type umwandeln (casten), welcher in einer anderen Variablen gespeichert ist

Hierfür hilft Convert.ChangeType weiter:

object foo = GetFoo();
Type t = typeof(double);
double bar = Convert.ChangeType(foo, t);

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.