Rizwan Ali Sabir
Rizwan Ali Sabir

Reputation: 478

Get all data in dictionary by using dictionary name

I need all data in a filled dictionary by using dictionary name below is my code

var data  = mAData.GetType().GetProperty("SEN").GetValue(mAData.SEN);

I do not know where i am missing please help. my finding is the problem is in GetValue() parameter

Upvotes: 0

Views: 60

Answers (1)

Patrick Hofman
Patrick Hofman

Reputation: 157038

You are getting the value from the property SEN. That property belongs to mAData, not to mAData.SEN. You need to give the instance to which the property belongs:

var data  = mAData.GetType().GetProperty("SEN").GetValue(mAData);

I hope this code is just for testing purposes, since usually you can just call mAData.SEN (unless it is not accessible due to its protection level).

Upvotes: 2

Related Questions