Solved

Load value types at runtime

Posted on 2006-07-14
1
236 Views
Last Modified: 2010-04-16
Hi!

I want to load at run time an instance of any .net valueType. example if I have this function
object getObject(string stObjectType, string stObjectValue)
{
    // Do some code to create a object of type stObjectType with the value stObjectValue
}
I need to do this with reflection. (I mean without a switch stament)

I'll thanks any help

Regards,

Jorge Arias
0
Comment
Question by:jorgearias
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 5

Accepted Solution

by:
paulb1989 earned 125 total points
ID: 17112956
object getObject(string stObjectType, string stObjectValue)
{
    return Convert.ChangeType(stObjectValue, Type.GetType(stObjectType));
}
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question