0

I have a resource class [Resource1] which contains some string properties. Normally, those properties can be accessed by:

string myValue = Resource1.Value1;

Now, both the class name (Full) and property name is given (as string) at runtime. So can I please ask how can I update the code to make it work?

string myValue = "Resource1"."Value1"; 

I have had a look at the suggested duplication. If I used the codes below:

 var type = Type.GetType("Full Name of Resource1");
 var myObject = Activator.CreateInstance(type);

The second line will generated a "No parameterless constructor defined for this object." error.

The resource class is auto-generated by ASP.NET (It is defined via Resource1.resc under the Properties. I'm doing this in a MVC project).

Thanks in advance.

Sun

Sun
  • 13
  • 6
  • possible duplicate of [c# instantiate class from string](http://stackoverflow.com/questions/2247598/c-sharp-instantiate-class-from-string) – Evil Dog Pie Mar 26 '15 at 10:10
  • Also, possible duplicate of [Get property value from string using reflection in C#](http://stackoverflow.com/q/1196991/3581917) – Evil Dog Pie Mar 26 '15 at 10:11

0 Answers0