菜要多喝水才會長大

如何用 C# 在執行階段建立新的 Class instance

by GDX on 一月.24, 2010, under 心情日記

利用 Class name

Type type = Type.GetType(className);

Object obj = Activator.CreateInstance(type);

Activator.CreateInstance 提供了許多多載方法

詳見 MSDN  參考資料


Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Archives

All entries, chronologically...