473,402 Members | 2,064 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,402 software developers and data experts.

Type.GetFields returning twice each field ...

DDE
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;
}

When I use the following code, I get each field twice, whatever I use as
BindingFlags:

Type theType = typeof(ContactInfo);
theFields = theType.GetFields(BindingFlags.Instance|BindingFla gs.Public);

foreach ( FieldInfo field in theFields ) {

Console.WriteLine(field.Name+" "+field.FieldType+" "+field.Attributes);

}

What's going wrong here?

Thanks, Dominique
Nov 15 '05 #1
2 3026
I can't reproduce your results. using your code I get each field once. Can
you post a fully working example....

Regards
Lee

"DDE" <dd*@iaireinfo.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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;
}

When I use the following code, I get each field twice, whatever I use as
BindingFlags:

Type theType = typeof(ContactInfo);
theFields = theType.GetFields(BindingFlags.Instance|BindingFla gs.Public);

foreach ( FieldInfo field in theFields ) {

Console.WriteLine(field.Name+" "+field.FieldType+" "+field.Attributes);

}

What's going wrong here?

Thanks, Dominique

Nov 15 '05 #2
DDE
Well, not so easy, my code is part of a Web Service. I'll try to reproduce
the problem in a simple app.

Thanks
Dominique

"Lee Alexander" <lee@No_Spam_Please_Digita.com> wrote in message
news:Oc**************@TK2MSFTNGP12.phx.gbl...
I can't reproduce your results. using your code I get each field once. Can
you post a fully working example....

Regards
Lee

"DDE" <dd*@iaireinfo.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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;
}

When I use the following code, I get each field twice, whatever I use as
BindingFlags:

Type theType = typeof(ContactInfo);
theFields = theType.GetFields(BindingFlags.Instance|BindingFla gs.Public);
foreach ( FieldInfo field in theFields ) {

Console.WriteLine(field.Name+" "+field.FieldType+" "+field.Attributes);

}

What's going wrong here?

Thanks, Dominique


Nov 15 '05 #3

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

Similar topics

2
by: Dave | last post by:
Is it possible to extract all the used variables (&type) from a piece of sourcecode, rather than doing it manually? Cheers, Dave
11
by: Neo | last post by:
Does anyone know how to get a list of the types in an Assembly without actually loading the Assembly into your app domain?
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"...
9
by: Phil | last post by:
I have a custom class that has been assigned to a variable and worked with, I now need to cast this class as a different class, which is in a separate assembly, not currently in the project. ...
2
by: Larry | last post by:
I'm having trouble finding the right method to determine at runtime the data type of the fields in a class. here's what I've got so far: Public Class ImgSubmissionRecord Public fileName As...
6
by: Charles Law | last post by:
I want to do something like this: obj = CType(value, Value.Type) Well, not exactly, but I think that captures the essence. I realise it won't work as I have written it, and it looks a bit like...
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...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.