how do i... iterate a struct?

  • Thread starter Thread starter Matteo Cima
  • Start date Start date
M

Matteo Cima

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.
 
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...
 
Structures can be serialized.

Drebin said:
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...
 
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" <[email protected]>
| 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: <[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: 62.94.140.163
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGXA06.phx.gbl!TK2MSFTNGXA05.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.
|
|
|
 
Back
Top