473,500 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# Get class properties

I'm trying to write a class that will get all the properties of a
class and store it in xml file. So far I'm able to do this on a basic
class, meaning a class that has no array's or instances of other
classes within it, just some basic properties (ie. strings, ints, etc)
Does anyone have an idea of how i'd iterate through a classes property
if it's an arraylist to grab the properties within the arraylist as
well?
Nov 17 '05 #1
1 10098
Using reflection you can obtain the MemberInfo property,
then objtain property types, check if it implements ICollection and then
iterate...

Type MyType =Type.GetType("System.IO.BufferedStream");
PropertyInfo[] propInfoArray = MyType.GetProperties();
ICollection collection = null;
object obj = null;
foreach (PropertyInfo propInfo in propInfoArray )
{
if ( (obj = propInfo.GetValue(null, null)) is ICollection )
collection = (ICollection)obj;
}
Iterate through collection object

--
Vadym Stetsyak aka Vadmyst

"jared lynch" <no******@developer.net> wrote in message
news:ej********************************@4ax.com...
I'm trying to write a class that will get all the properties of a
class and store it in xml file. So far I'm able to do this on a basic
class, meaning a class that has no array's or instances of other
classes within it, just some basic properties (ie. strings, ints, etc)
Does anyone have an idea of how i'd iterate through a classes property
if it's an arraylist to grab the properties within the arraylist as
well?

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
10324
by: Jeff Thies | last post by:
I have a number of elements of "some-class". I'd like to change the styles of some-class: from ..some-class{color: red; display: block} to
7
2391
by: Koda | last post by:
What is the difference between class fields and class properties? Thanks Mike
1
2625
by: Brent | last post by:
I can't seem to locate any easy way to create dynamic class properties. Essentially, I want to take the column headers from a data result set, create a property having the column header name, and...
7
1224
by: Dave | last post by:
I was just wondering what the difference between using readonly properties in a class definition instead of using a function? Example: Public Class myClass Private privateValues() as Long '...
1
2497
by: John Dann | last post by:
I'm realising that there's something important that I don't understand about acccessing class properties. In fact I'm not even sure that I can explain clearly what it is that I don't understand!...
3
1931
by: Dan | last post by:
Is it possible to dynamically create and populate properties? Below is my class. I would like to define properties for each of the items in my two arrays without actually defining each one. (There...
7
1286
by: mn_ms_user | last post by:
Can someone point me in the right direction? I need to wrap some class properties into XML tags in C#. I just need the XML tags and not the XML document information. Thanks.
6
1425
by: manstey | last post by:
I have a ClassWrapper that wraps around a third party database object. Each database object has a set of properties, like columns in a relational database. I want my wrapper to generate a...
3
1712
by: Michael B. Trausch | last post by:
Hello everyone, I am having a problem with static class properties that I suspect is somewhat trivial, but I don't understand what is wrong. I am using GNU C++ on Windows, though I am (hoping)...
2
6111
by: peridian | last post by:
Hello, I should have made a note of which version of php 5 I am currently using, but I didn't (I'm pretty sure it's 5.2.2). Ayway, I just want to clarify that my understanding of the static...
0
7136
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,...
0
7018
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
7232
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...
1
6906
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7397
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...
0
5490
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,...
0
4611
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...
0
3110
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.