Click here to Skip to main content
15,880,037 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone,
My problem is that, I assign values to properties of unknown object. Unfortunately, some properties are can writable(set not implemented or read-only etc.). So, I tried to search the field which it have same type and same value, but it does not look like an optimum solution and it's failed. Is there any way to reach fieldInfo or to set an value to non-writable property.

Thanks in advance.
Rob Grainger 31-Mar-14 8:47am    
I don't think there is a simple way. It may be possible using reflection, but even then not guaranteed - not every property is a simple field-accessor. Not every field name matches the property name.
It might be possible be examining the emitted IL and looking for an instruction reading the property, but I suspect that's an overkill, and even then non necessarily reliable.
Mahmut Koyuncu 7-Apr-14 4:21am    
Thanks for your response, you are right. I could not find a simple way too.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900