Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

Load value types at runtime

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
jorgearias
Asked:
jorgearias
1 Solution
 
paulb1989Commented:
object getObject(string stObjectType, string stObjectValue)
{
    return Convert.ChangeType(stObjectValue, Type.GetType(stObjectType));
}
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now