473,387 Members | 1,664 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

GetFields not working?

FieldInfo[] fields = type.GetFields();

works and returns all public fields, but when I do

FieldInfo[] fields = type.GetFields(BindingFlags.Public);

I get nothing!! Whats going on? (again, its that simple... if I delete
BindingFlags.Public I get all public fields but if I don't then I get
nothing)

Thanks,

Jon
Apr 1 '08 #1
3 7745
You need to specify whether you want instance or static members by or'ing
BindingFlags.

I believe GetFields() does Public | Instance.

"Jon Slaughter" <Jo***********@Hotmail.comwrote in message
news:KI*******************@newssvr29.news.prodigy. net...
FieldInfo[] fields = type.GetFields();

works and returns all public fields, but when I do

FieldInfo[] fields = type.GetFields(BindingFlags.Public);

I get nothing!! Whats going on? (again, its that simple... if I delete
BindingFlags.Public I get all public fields but if I don't then I get
nothing)

Thanks,

Jon


Apr 1 '08 #2

"Fredo" <fr***@hotmail.comwrote in message
news:Qf******************************@giganews.com ...
You need to specify whether you want instance or static members by or'ing
BindingFlags.

I believe GetFields() does Public | Instance.
Thanks, that was the issue.

Jon
Apr 1 '08 #3

"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP*********************@msnews.microsoft.com. ..
Jon Slaughter <Jo***********@Hotmail.comwrote:
>FieldInfo[] fields = type.GetFields();

works and returns all public fields, but when I do

FieldInfo[] fields = type.GetFields(BindingFlags.Public);

I get nothing!! Whats going on? (again, its that simple... if I delete
BindingFlags.Public I get all public fields but if I don't then I get
nothing)

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
See Fredo's reply.
Apr 1 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: DDE | last post by:
Hi, I have defined he following class: public class ContactInfo { public string con_nom; public string con_prenom; public string con_fonction; public string con_email; }
1
by: The Last Gunslinger | last post by:
I have a method that takes a type that relates to an enum and then gets all the Description attributes or the name and returns them in a string array. This was working until I added the check to...
1
by: Pascual ataeda | last post by:
Can someone tell me a case where Module.GetFields() doesn't return zero FieldInfos? Is there a way to have field that are accesible by the entire module? If so, how can I declare these "global"...
5
by: Martin Heuckeroth | last post by:
Hi We are working on a webservice application and are having some problems with the cookies and/or sessions. We have them working on our intranet but then its not working on the internet. We...
5
by: tshad | last post by:
I have been working with setting my drop boxes to allow double clicking to select an item. It worked fine until I made some changes. I then stripped the page down to the bare essentials to find...
8
by: jojobar | last post by:
Okay, I am trying to do is to test the webresource in 2.0 1. I created a new project with assembly name (and default assembly name) "Office". 2. I added the following to the AssemblyInfo.cs...
3
by: Trewq | last post by:
Hello you, Problem is that Type.GetFields does not return InnerList from a class that inherits from CollectionBase. I have a class: Public Class MyCollection Inherits...
9
by: MSDNAndi | last post by:
Hi, I have a set of simple webservices calls that worked fine using .NET Framework 1.0. I am calling a Java/Apache based webservices, the calling side is not able to supply a proper WSDL. ...
5
by: TS | last post by:
i have tried .GetFields (BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic ); but it wont get the protected properties declared on the type's base class. How do i get it to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.