How to SetValue a Dynamic Type Field?

This is very likely the wrong way to do something. If you could give a more concrete example of what you're trying to accomplish, we could perhaps give some alternative ways to do it.

This is very likely the wrong way to do something. If you could give a more concrete example of what you're trying to accomplish, we could perhaps give some alternative ways to do it. That being said, you don't have an instance of TypeName, so you obviously can't have anything to go in the place of the "?".

You could use System. Activator to create a new instance of that TypeName though. Example: string typeName = Request.

QueryString"TypeName"; Type t = Type. GetType(typeName); object instance = Activator. CreateInstance(t); t.

GetField("SomeField"). SetValue(instance, "").

– Braveyard Oct 6 '09 at 4:19 2 System. Activator is what you use to create an instance. – Jimmy Oct 6 '09 at 4:20 Thanks, besides that solution, is there any other solution you know and suggest me?

– Braveyard Oct 6 '09 at 4:21 1 Without known what you're using it for? No. – Joel Coehoorn Oct 6 '09 at 4:23 1 If you know the set of those type which you'll be allowing through query string then you can use Switch - Case to identify which type is it once you identify the type you can assign its fields.

Yes, it doesn't sound neat but it'll certainly server the purpose. If you identified the type name you didn't even need to use type object to create its instance. – S M Kamran Oct 6 '09 at 4:42.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions