473,395 Members | 1,742 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,395 software developers and data experts.

how do i... iterate a struct?

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
3 3291
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
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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Randall Smith | last post by:
In the case I know how may times I want to iterate, one way to do it is like this: for i in range(100000): dothis() I like how clean this syntax is, but this method is very wasteful. The...
2
by: martin | last post by:
hi, I am using vb.net. I have wrote a data access class and one of my methods returns a dataset. I would like to iterate through this, although this is proving problematic for me. Can...
2
by: James Doran | last post by:
Hello, I'd like to iterate through each Page of my ASP.NET project from within a Custom web control and access the Page.Controls collection. I've tried using Reflection on the web project...
6
by: eBob.com | last post by:
How do you make a loop iterate early without using a GoTo? (I guess I've done too much structured programming and I really don't like using GoTos.) Here's my code ... For Each Thing As OFI...
5
by: jaso | last post by:
Hi, If have a structure of a database record like this: struct record { char id; char title; ... }; Is there some way to find out how many member variables there is in the struct and then...
3
by: Suneeel | last post by:
Hi All, I'm having trouble with iterating through an STL map. Firstly, for an empty map, will map.begin() be equal to map.end()? If this is true, the program should not be entering the while...
2
by: foxx | last post by:
I have 2D data structure, modelled as a vector of vectors of ints. I'd like to visit each one of the ints and call a function on them. Is there some smart way of doing this without using a double...
1
by: =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post by:
Hi, Is there a way ( perhaps throgh refleksion) to iterate through the colors of the System.Drawing.Color struct. foreach (Color color in .... i dont know.... regards Jesper
1
by: prathna | last post by:
Hi .. I have a logic:iterate tag which will display 5 rows each row with a drop downlist and 2 textfields.now by default all the rows will be shown.how do i hide all the rows except the first...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...

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.