15,916,842 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by SaiprasadVer (Top 6 by date)
SaiprasadVer
13-Jan-15 6:42am
View
public void WriteResultToXml(List<Object> objTestResults)
{
foreach (var item in objTestResults)
{
PropertyInfo[] propertyList = item.GetType().GetProperties();
foreach (var property in propertyList)
{
object value = Activator.CreateInstance(property.PropertyType);
Console.WriteLine(property.GetValue(value, null));
}
}
Console.ReadLine();
}
I am observing TargetException when i call GetValue() function
SaiprasadVer
13-Jan-15 5:07am
View
Yes. I know I was close. Thank you.
SaiprasadVer
13-Jan-15 4:48am
View
I would like to know how I can access fields of an particular Type which is type casted to Object Type. Suppose I have an and Employee object(Employee class with its members) which is type casted and placed inside an Object type. Using reflection how can i get the values of those members. The function that i define wont be knowing what type the Object variable is holding.
SaiprasadVer
13-Jan-15 4:44am
View
I am new to this. For now, all i want is to just access each item in the List and then print values of each field within that item. Does this explain you my problem statement!!
SaiprasadVer
13-Jan-15 4:35am
View
Code below
object value = new object();
foreach (var item in objTestResults)
{
Type type = item.GetType();
PropertyInfo[] propertyList = type.GetProperties();
foreach (var property in propertyList)
{
Console.WriteLine(property.GetValue(value, new object[] {property}));
}
}
I am figuring it out how i can achieve this. For now, the above code is what i have.
SaiprasadVer
13-Jan-15 4:28am
View
Nope... i wont be knowing the Type that is in the List. My function should get the properties and thier respective values.
Show More