473,513 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1235
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1172
by: Gunner | last post by:
I am trying to create a generic form driven the database. I want to be able to run create Crystal reports from this genric page and only want to have to enter some info in the database and drop the...
3
1402
by: Peter Oliphant | last post by:
Trying to save/load a class instance to a file is tough. The reason is because there is no way to preserve its type other than by conventon. For eample, one can save all the states of the members...
3
1079
by: Ernesto Díaz | last post by:
Hi I need to instance a class at runtime, at runtime a 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...
2
883
by: Ernesto Díaz | last post by:
Hi I need to instance a class at runtime, at runtime a 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...
20
27729
by: Shawnk | last post by:
I would like to get the class INSTANCE name (not type name) of an 'object'. I can get the object (l_obj_ref.GetType()) and then get the (l_obj_typ.Name) for the class name. I there any way of...
2
2121
by: TEK | last post by:
Hello We're having a issue with a part of our app that is very strange, and I'm unable to see that it should be possible. We have: A collection (ActivityCollection) that is inherited from a...
16
2671
by: alexia.bee | last post by:
Hi all, In some weird reason, excel instance won;t die if i remove the comment from 4 lines of setting values into struct. here is a snipcode public...
4
3953
by: =?Utf-8?B?SmFzb24gUmV5bm9sZHM=?= | last post by:
(using .net 2.0) Say you have a class structure like this: class Address .... end class class Person FirstName
45
2960
by: =?Utf-8?B?QmV0aA==?= | last post by:
Hello. I'm trying to find another way to share an instance of an object with other classes. I started by passing the instance to the other class's constructor, like this: Friend Class...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7161
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7539
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7101
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5686
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5089
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3234
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1596
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.