471,336 Members | 1,265 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,336 software developers and data experts.

Instance a class at runtime

Hi

I need to instance a class at runtime, at runtime I can get the name in a
string, i would like to know if its possible to instance the class at
runtime with the name in a string.

Thanks for your assistance.

Ernesto Díaz
Feb 23 '06 #1
4 1154
You can get the Type using Type.GetType(string) and then you can use one of
the CreateInstance methods of the Activator class.
http://msdn.microsoft.com/library/de...ancetopic1.asp

--
Tim Wilson
..NET Compact Framework MVP

"Ernesto Díaz" <je****@vianney.com.mx> wrote in message
news:eP**************@TK2MSFTNGP12.phx.gbl...
Hi

I need to instance a class at runtime, at runtime I can get the name in a
string, i would like to know if its possible to instance the class at
runtime with the name in a string.

Thanks for your assistance.

Ernesto Díaz

Feb 23 '06 #2
Ernesto,
You can use the Activator.CreateInstance or you can use reflection the get
the constructor and invoke it.
--

Stoitcho Goutsev (100)

"Ernesto Díaz" <je****@vianney.com.mx> wrote in message
news:eP**************@TK2MSFTNGP12.phx.gbl...
Hi

I need to instance a class at runtime, at runtime I can get the name in a
string, i would like to know if its possible to instance the class at
runtime with the name in a string.

Thanks for your assistance.

Ernesto Díaz

Feb 23 '06 #3
KH
See Assembly.GetType() and Activator.CreateInstance()
"Ernesto DÃ*az" wrote:
Hi

I need to instance a class at runtime, at runtime I can get the name in a
string, i would like to know if its possible to instance the class at
runtime with the name in a string.

Thanks for your assistance.

Ernesto DÃ*az

Feb 23 '06 #4
Does anybody have an example to help me understand ?

Thanks

Ernesto Díaz
Feb 23 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Peter Oliphant | last post: by
3 posts views Thread by Ernesto Díaz | last post: by
2 posts views Thread by Ernesto Díaz | last post: by
2 posts views Thread by TEK | last post: by
4 posts views Thread by =?Utf-8?B?SmFzb24gUmV5bm9sZHM=?= | last post: by
45 posts views Thread by =?Utf-8?B?QmV0aA==?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.