473,698 Members | 2,883 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3316
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.Reflecti on - it
lets you programatically pull out information like this...
"Matteo Cima" <ma*********@di gisoft.it> wrote in message
news:OR******** ******@TK2MSFTN GP12.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. prodigy.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.Reflecti on - it
lets you programatically pull out information like this...
"Matteo Cima" <ma*********@di gisoft.it> wrote in message
news:OR******** ******@TK2MSFTN GP12.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*********@di gisoft.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.publi c.dotnet.langua ges.csharp
| NNTP-Posting-Host: 62.94.140.163
| Path:
cpmsftngxa06.ph x.gbl!TK2MSFTNG XA06.phx.gbl!TK 2MSFTNGXA05.phx .gbl!TK2MSFTNGP 0
8.phx.gbl!TK2MS FTNGP12.phx.gbl
| Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1803 08
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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
1475
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 list created by range(100000) consumes a fair amount of memory and it is only used to iterate.
2
2179
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 anybody please point out the addition that I would need to the follwoing code.
2
1953
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 assembly, but the controls collection count was zero. While this method gives details of the private controls in each page, I need access to actual instances of the controls to interrogate their individual properties.
6
3645
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 In FileInfo If Thing.Displayed <> True Then GoTo Iterate 'skip this entry; try next one End If
5
29361
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 iterate through them?
3
8494
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 loop to delete the map's contents... But, it does, thus causing a segmentation fault when I try to delete.. Is this hapening because the map is empty?
2
4194
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 for loop,? I mean how could I go about creating a new kind of iterator that knows how to transverse all the ints in some sequence; or better still, does STL already have such a feature?
1
6265
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
2366
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 one.i know how to show/hide a row when its not dynamic.but i dont know how to do it when its logic iterate tag. <logic:iterate indexId="index" id="phoneItem" name="nameForm" property="results"> <% String dropdownType = "results.dropdownType";...
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8610
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9031
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8873
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7740
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.