Solved

Load value types at runtime

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now