By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,152 Members | 2,159 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,152 IT Pros & Developers. It's quick & easy.

Type.GetFields returning twice each field ...

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.