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

how do i... iterate a struct?

P: n/a
hi!
i have a struct like:

Public struct conf
{
public bool debug=false;
public int opPalm=-1;
public int neMess=0;
public bool caPart = false;
}
how can i iterate the members of the struct to get the names of the
variables inside?
I'd like to save the entire struct values into an xml and then retrieve the
saved configuration.

Regards,
Matteo.
Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
The better solution might be to make it into a class and just serialize it
to disk?

If you do want to do what you said, take a look at System.Reflection - it
lets you programatically pull out information like this...
"Matteo Cima" <ma*********@digisoft.it> wrote in message
news:OR**************@TK2MSFTNGP12.phx.gbl...
hi!
i have a struct like:

Public struct conf
{
public bool debug=false;
public int opPalm=-1;
public int neMess=0;
public bool caPart = false;
}
how can i iterate the members of the struct to get the names of the
variables inside?
I'd like to save the entire struct values into an xml and then retrieve the saved configuration.

Regards,
Matteo.

Nov 15 '05 #2

P: n/a
Structures can be serialized.

"Drebin" <tR*************@hotmail.com> wrote in message
news:3p**********************@newssvr28.news.prodi gy.com...
The better solution might be to make it into a class and just serialize it
to disk?

If you do want to do what you said, take a look at System.Reflection - it
lets you programatically pull out information like this...
"Matteo Cima" <ma*********@digisoft.it> wrote in message
news:OR**************@TK2MSFTNGP12.phx.gbl...
hi!
i have a struct like:

Public struct conf
{
public bool debug=false;
public int opPalm=-1;
public int neMess=0;
public bool caPart = false;
}
how can i iterate the members of the struct to get the names of the
variables inside?
I'd like to save the entire struct values into an xml and then retrieve

the
saved configuration.

Regards,
Matteo.


Nov 15 '05 #3

P: n/a

Hi Matteo,

To save the struct's configuration, you can serialization this structure.
Then you can deserialize the structure and use reflection to retrive the
structure's member.

HTH.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "Matteo Cima" <ma*********@digisoft.it>
| Subject: how do i... iterate a struct?
| Date: Thu, 28 Aug 2003 18:45:52 +0200
| Lines: 21
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <OR**************@TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: 62.94.140.163
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGXA06.phx.gbl!TK2MSFT NGXA05.phx.gbl!TK2MSFTNGP0
8.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:180308
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| hi!
| i have a struct like:
|
| Public struct conf
| {
| public bool debug=false;
| public int opPalm=-1;
| public int neMess=0;
| public bool caPart = false;
| }
|
|
| how can i iterate the members of the struct to get the names of the
| variables inside?
| I'd like to save the entire struct values into an xml and then retrieve
the
| saved configuration.
|
| Regards,
| Matteo.
|
|
|

Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.