Solved

Load value types at runtime

Posted on 2006-07-14
1
237 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

734 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