473,800 Members | 2,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GetFields not working?

FieldInfo[] fields = type.GetFields( );

works and returns all public fields, but when I do

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

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

Thanks,

Jon
Apr 1 '08 #1
3 7806
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.comwrot e in message
news:KI******** ***********@new ssvr29.news.pro digy.net...
FieldInfo[] fields = type.GetFields( );

works and returns all public fields, but when I do

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

I get nothing!! Whats going on? (again, its that simple... if I delete
BindingFlags.Pu blic 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******** *************** *******@giganew s.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.co mwrote in message
news:MP******** *************@m snews.microsoft .com...
Jon Slaughter <Jo***********@ Hotmail.comwrot e:
>FieldInfo[] fields = type.GetFields( );

works and returns all public fields, but when I do

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

I get nothing!! Whats going on? (again, its that simple... if I delete
BindingFlags.P ublic 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
3045
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
3847
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 see if the field was a IsSpecialName as I was getting a value__ field I did not want. Now, GetFields only ever returns a zero length array. I cannot see what I have done. The code is below
1
1663
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" fields? Any information would be much appreciated. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
5
2813
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 have been looking our asses off but can not find a working solution. the code we came up with is ...
5
3066
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 out why it quit working. I found that if I didn't have a linkbutton, it quit working????????? If I changed the linkbutton to a regular button, it quit working. Here is the page:
8
2537
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 file (present under the Properties folder of the project) 3. Now I created a file called test.js on the root folder of the project,
3
4830
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 System.Collections.CollectionBase ...
9
3222
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. What it does is to call a webservice with two parameters, one being a integer, the other one being a "String" which contains XML (not the best practice, however that is the target interface and we cannot change that).
5
2721
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 work...(.FlattenHierarchy is for only static ones.)
0
9691
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10505
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10035
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7580
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6813
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.