1

I help with reflection, follows the code below where I explain my need, within the foreach I want to get the public private name by name

class Test
{
   private string _test;

   public string Test
    {
        get { return _test; }
        set { _test= value; }
    }
}

foreach (PropertyInfo Prop in new Test().GetType().GetProperties())
{
       Prop.Name = Name Public = Test
       I Want Private Name = _test
       How to do?
}
cef
  • 11
  • 1
  • http://stackoverflow.com/questions/14322660/using-reflection-to-determine-which-fields-are-backing-fields-of-a-property – Habib Nov 26 '13 at 19:29
  • Exact duplicate of question linked by @Habib. Unless you are willing to read IL of method there is not much you can do. – Alexei Levenkov Nov 26 '13 at 19:36
  • I have not found the solution in question quoted above – cef Nov 26 '13 at 19:38
  • there is the possibility of doing what I want? – cef Nov 26 '13 at 19:39
  • There are decompilers (Reflector/ILSpy) or libraries (like Mono Cecil) that let you read IL. Start with [GetMethodBody](http://msdn.microsoft.com/en-us/library/system.reflection.methodbase.getmethodbody%28v=vs.110%29.aspx) and parse IL of the method to find mapping (if one even exist for particular property). – Alexei Levenkov Nov 26 '13 at 19:43
  • i need get private name (fiedinfo) inform the property in – cef Nov 26 '13 at 20:01

0 Answers0