Ah yes - good point. Thanks.
On Fri, 30 Jun 2006 00:07:57 +0200, "Kornél Pál" <[EMAIL PROTECTED]> said: > This is an instance field so you should use > GetFields(BindingFlags.NonPublic > | BindingFlags.Instance). > > The field is not removed, that's why you get the warning so that the > compiler warns you that you should probably remove the field if you are > sure > that you don't need it. You can check the presence of the field using > tools > like monodis, ildasm or Reflector. > > Kornél > > ----- Original Message ----- > From: <[EMAIL PROTECTED]> > To: <[email protected]> > Sent: Thursday, June 29, 2006 11:56 PM > Subject: [Mono-list] Reflection of non-public fields > > > > I'm not entirely sure I've got this right so I thought I'd run it past > > "the list" before I created a bug report. > > > > On running [1] I would expect to see "Hello World" but no output is > > produced. When I compile I see a couple of warnings about the fields > > not being used - is the compiler being clever here and removing the > > fields entirely? > > > > -- Colin > > > > [1]: > > using System; > > using System.Reflection; > > public class test_t { > > private string Hello; > > private string World; > > public static void Main() { > > foreach (FieldInfo fi in > > typeof(test_t).GetFields(BindingFlags.NonPublic)) { > > Console.Write("{0} ", fi.Name); > > } > > Console.WriteLine(); > > } > > } > > _______________________________________________ > > Mono-list maillist - [email protected] > > http://lists.ximian.com/mailman/listinfo/mono-list > _______________________________________________ Mono-list maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-list
