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

Reflection Types

Hey,

I'm attempting to use reflection in order to get the types of properties
in a class. However, I seem to be having trouble determining exactly which
type I am getting. In the foreach of running through the properties, the
PropertyInfo.Name does cycle through all the properties, however, if you
check the PropertyInfo.GetType().ToString() it is always
"System.Reflection.PropertyInfo". Which technically makes sense. What
doesnt make sense is that the PropertyInfo.GetType().IsEnum SEEMS to work
for each property.

So, my question is, how do I get the type of the property I am on?

Does this make sense?

- Roger
Nov 16 '05 #1
3 2202

PropertyInfo.PropertyType is what you're looking for.

Jose Solorzano

Roger Webb wrote:
Hey,

I'm attempting to use reflection in order to get the types of properties in a class. However, I seem to be having trouble determining exactly which type I am getting. In the foreach of running through the properties, the PropertyInfo.Name does cycle through all the properties, however, if you check the PropertyInfo.GetType().ToString() it is always
"System.Reflection.PropertyInfo". Which technically makes sense. What doesnt make sense is that the PropertyInfo.GetType().IsEnum SEEMS to work for each property.

So, my question is, how do I get the type of the property I am on?

Does this make sense?

- Roger


Nov 16 '05 #2
Thanks... That was it. I dont know why I was missing it.

- Roger

"Jose Solorzano" <jh******@hotmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...

PropertyInfo.PropertyType is what you're looking for.

Jose Solorzano

Roger Webb wrote:
Hey,

I'm attempting to use reflection in order to get the types of

properties
in a class. However, I seem to be having trouble determining exactly

which
type I am getting. In the foreach of running through the properties,

the
PropertyInfo.Name does cycle through all the properties, however, if

you
check the PropertyInfo.GetType().ToString() it is always
"System.Reflection.PropertyInfo". Which technically makes sense.

What
doesnt make sense is that the PropertyInfo.GetType().IsEnum SEEMS to

work
for each property.

So, my question is, how do I get the type of the property I am on?

Does this make sense?

- Roger

Nov 16 '05 #3
So, my question is, how do I get the type of the property I am on?

The PropertyType property gets the type of the property.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
Nov 16 '05 #4

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

Similar topics

2
by: UJ | last post by:
Can somebody point me to an explanation of what Reflection is? I've tried looking in the help and it's not very helpful. TIA - Jeff.
1
by: Mike Malter | last post by:
I am just starting to work with reflection and I want to create a log that saves relevant information if a method call fails so I can call that method again later using reflection. I am...
1
by: Pieter Breed | last post by:
Hi All, I am trying to use the attribute/reflection system to as much potential as I can think of, but I've run into a snag. I would appreciate it if someone would point me in the right...
3
by: System.Reflection Activator | last post by:
************************************** //Load the Assembly Assembly a = Assembly.LoadFrom(sAssembly); //Get Types so we can Identify the Interface. Type mytypes = a.GetTypes(); BindingFlags...
11
by: Aaron Queenan | last post by:
Given the classes: class Class { public static implicit operator int(Class c) { return 0; } } class Holder
3
by: HL | last post by:
The requirement is to send some information to other objects. The objects to whom the information has to be sent is not available at compile time. The names of the types (objects) will be provided...
2
by: Luis Arvayo | last post by:
Hi, In c#, I need to dynamically create types at runtime that will consist of the following: - inherits from a given interface - will have a constructor with an int argument
0
by: Rob | last post by:
Hello, I'm new to C# and have a question regarding factoring through reflection. I have a database filled with data represented by name and value pairs. Each name has a identically named...
1
by: Erland | last post by:
Hi, I want to retreive different namespaces available within an Assembly using Reflection. Is this possible? Can i retreive a namespace within an Assembly using " Type " ? My question is how...
17
by: raylopez99 | last post by:
What good is C# Reflection, other than to find out what types are in an assembly? And to dynamically invoke methods in an assembly (.dll or .exe)? Also, bonus question, can you use Reflection...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
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...
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
Oralloy
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,...
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...

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.