3 1217
Following queries the available properties, then loops over them,
printing the name and value of each:
foreach(PropertyDescriptor prop in
TypeDescriptor.GetProperties(obj)) {
Console.WriteLine("{0}\t{1}", prop.Name,
prop.GetValue(obj));
}
Marc
What is one of the property is itself composite and has multiple sub
properties so to speak?
Regards
"Marc Gravell" <ma**********@gmail.comwrote in message
news:eD**************@TK2MSFTNGP02.phx.gbl...
Following queries the available properties, then loops over them, printing
the name and value of each:
foreach(PropertyDescriptor prop in
TypeDescriptor.GetProperties(obj)) {
Console.WriteLine("{0}\t{1}", prop.Name, prop.GetValue(obj));
}
Marc
Rinse, repeat... i.e. the same again, for the value returned from:
object innerValue = prop.GetValue(obj);
Note that there is a chance that innerValue could be null; in this
case, you can use:
PropertyDescriptorCollection innerProps =
TypeDescriptor.GetProperties(prop.PropertyType);
This will give you the properties associated with the Type matching
the property - one minor caveat: if the value implements
ICustomTypeDescriptor, then it won't have chance to speak for itself,
since this only works on instances. From 2.0, the preferred approach
for custom properties is TypeDescriptionProvider, which works on both
the Type and an instance.
Marc This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: kj |
last post by:
Is there any way to programmatically discover and inspect *all*
the properties of an object, even those that are not enumerable
through a for/in loop?
Thanks!
kj
--
NOTE: In my address...
|
by: ytrewq |
last post by:
Should dynamic ("expando") properties be restricted to native and
user-defined objects? Or should host objects - such as references to
the browser or a plug-in or to the document and its elements -...
|
by: Lyn |
last post by:
Hi,
This question may seem a bit academic...
To learn more about Access VBA, I have been enumerating the properties of
various form controls. This was mostly successful and I have learned a lot...
|
by: Sunny |
last post by:
Hi,
I have an old problem which I couldn't solve so far. Now I have found a post
in that group that gave me an idea, but I can not fully understand it.
The problem is: I'm trying to use a...
|
by: Hardy Wang |
last post by:
Hi,
I am using DirectoryEntry to access IIS properties. After searching
MSDN, I get "The Internet Information Services (IIS), and WinNT providers do
not currently support Count, so each will throw...
|
by: Martin Montgomery |
last post by:
I have, for example, a property called myProperty. I would like, when using a property grid to display the property name as "My Property". Is this possible. Is there an attribute etc
Thank
...
|
by: Paul Mcilreavy |
last post by:
Hi, i would like to get some view points on the use of properties within
classes. My belief is that properties should generally be used to return
values of private members. They should not do...
|
by: Max |
last post by:
Hi, there,
Is there a good way to get an Object's properties' names.
eg. obj={a:"aa",b:"bB",c:"Cc"};
All I mean is to get the names of "a", "b", "c". but not the values
"aa", "bB", "Cc".
...
|
by: David C. Ullrich |
last post by:
Having a hard time phrasing this in the form
of a question...
The other day I saw a thread where someone asked
about overrideable properties and nobody offered
the advice that properties are...
|
by: optimistx |
last post by:
A variable in global scope
var a1 = 'contents of global variable a1';
can be references (with some limitations) as
window; // or
window.a1; // or even
window;
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
| |