Want to add a new property to a class, can I use anonymous functions for this?
Posted
by Blankman
on Stack Overflow
See other posts from Stack Overflow
or by Blankman
Published on 2010-05-21T15:55:32Z
Indexed on
2010/05/21
16:00 UTC
Read the original article
Hit count: 216
c#
|anonymous-function
I have 2 Lists:
List<User>
List<UserStats>
So I want to add a property Count to User (it doesn't have one now, and I can't change the implementation at this point).
For a web service call, that returns json, I want to modify the User object.
Basically I add the Users to a collection. So I want to add a modified user class (via anonymous functions?) to the collection before I serialize it to json.
So something like:
loop users {
user.Count = userstats[user.ID].Count;
list.Add(user);
}
is this possible? how?
© Stack Overflow or respective owner