It's possible to create variable to hold fields of class dynamically???
        Posted  
        
            by yossharel
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by yossharel
        
        
        
        Published on 2010-04-27T13:44:03Z
        Indexed on 
            2010/04/27
            13:53 UTC
        
        
        Read the original article
        Hit count: 356
        
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?
© Stack Overflow or respective owner