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

HELP! need reflection help

M
Given string propertyName, I want to return the value of a property,
like so:

getPropertyValueByFieldName(string propertyName, object myClass){}

Can someone please give me the syntax required for reflecting on a class
this way?

So far I can't get this to work:

object propertyValue =

myClass.GetType().GetProperty(Convert.ToString(pro pertyName)).GetValue(myClass,null);


Nov 15 '05 #1
1 984
M
This seems to work ok.
http://tinyurl.com/rtpn


public object getFieldByPropertyName(string propertyName, object myClass)
{
Type t = myClass.GetType();
object v;
v = (object) t.InvokeMember(propertyName,
BindingFlags.DeclaredOnly |
BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.GetProperty, null, myClass, null);

return v;
}

M wrote:
Given string propertyName, I want to return the value of a property,
like so:

getPropertyValueByFieldName(string propertyName, object myClass){}

Can someone please give me the syntax required for reflecting on a class
this way?

So far I can't get this to work:

object propertyValue =

myClass.GetType().GetProperty(Convert.ToString(pro pertyName)).GetValue(myClass,null);



Nov 15 '05 #2

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

Similar topics

0
by: Steven Green | last post by:
I need some help to get a training grant. If you are responsible for hiring Oracle professionals please read on. I want to become an Oracle DBA and am seeking to take a DBA certificate program....
6
by: mike | last post by:
Hello, After trying to validate this page for a couple of days now I was wondering if someone might be able to help me out. Below is a list of snippets where I am having the errors. 1. Line 334,...
3
by: Tommy Lang | last post by:
I am working on this project and I need some help/pointers/comments to get me started, I am stuck. The program will be used to store information in an array while it is running. I need to store...
4
by: Scott Holland | last post by:
HELP - Need to connect to DB2 database on AIX from NT server. Also AS/400 from NT Server -- I am experienced in ORACLE and a novice at DB2. What tools would be the equivalent of Net*8 or...
2
by: bryan | last post by:
I have a situation that's pretty delicate that I need some help on. I've been stumped for awhile I just need some advice on the best possible solution. The problem: I have a site I'm making...
16
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client...
2
by: Shodos | last post by:
How pop-up Download box when a button is pressed in c# or javascript Thanks inadvance
0
by: [Cool staff!||Hi! I think this need for || Help me | last post by:
http://con-cern.org/files/2007/5/xenical-21024312.html cheap xenical http://con-cern.org/files/2007/5/auto-21024411.html auto loan refinance ...
2
by: Amar | last post by:
I have XML Data: <REQUEST> <PARAMETERS> <PPM Name="CCCS Filed Date" value="xxxx"></PPM> </PARAMETERS> <RECORD _FiledDate="12/15/2003"></RECORD> </REQUEST>
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.