c# - What's wrong with this reflection code? GetFields() is returning an empty array -


C #, Net 2.0

Here's the code (I removed all my domain-specific stuff and It still gives an empty array):

  using the system; Using System.Collections.Generic; Using System.Text; Using the system. Namespace Console Application 1 {Class Program {Static Zero Main (String [] ARG) {ChildClass cc = New ChildClass (); Cc.OtherProperty = 1; Fieldinfo [] fi = c. Gettype () GetFields (); Console.WriteLine (fi.Length); Console.ReadLine (); }} Class base class & lt; T & gt; {Private int mover; {{MyVar; public IT information} } Set {myVar = value; }}} Class Child Class: Base Class & lt; ChildClass & gt; {Private int mover; Public Inc. {property {myVar; } Set {myVar = value; }}}}}  

without parameters GetFields () Return the Public field if you want non-public, then use it:

  cc.GetType (). GetFields (BindingFlags.Instance | BindingFlags.NonPublic);  

or the appropriate combination you want - but you must do have at least one example and still , Otherwise it can not be found either by both of you, and in fact the public sector, to get everything:

  cc.GetType (). GetFields (BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -