[Mono-list] Reflection of non-public fields

Trimble, Nathan G nathan.trimble at pnl.gov
Thu Jun 29 18:08:11 EDT 2006

I get no output in VS 2003 and the same warnings, looks consistent.

Nate Trimble

-----Original Message-----
From: mono-list-bounces at lists.ximian.com
[mailto:mono-list-bounces at lists.ximian.com] On Behalf Of
colin at breame.net
Sent: Thursday, June 29, 2006 2:57 PM
To: mono-list at lists.ximian.com
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

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);
Mono-list maillist  -  Mono-list at lists.ximian.com

More information about the Mono-list mailing list