It's possible to create variable to hold fields of class dynamically???
- by yossharel
hi all,
In my 'Person' class, I have some fields like 'firstname','lastname','nickname' and so on.
I want to write code to search dynamically, sometimes by 'firstname' and sometimes by 'nickname' field.
The code I want to write, should be like this:
Object someVariable = "firstname";
Person result = ListOfPerson.Where(p => p.someVariable = "exp").FirstOrDefault();
Can anyone Know if it's possible?