Reputation: 21
I'm working on a way to handle parsing strings to types without knowing what types they are being parsed to. Specifically bools/ints/dates etc.
I am considering using a Dictionary<Type, Func <string,dynamic>> to do this but want to know if there is going to be a boxing/unboxing of the value.
Upvotes: 1
Views: 44
Reputation:
Yes, the value type instances you return from your funcs will be boxed (you effectively have a dictionary that stores Func<string, object>
s).
When you invoke the func and try to assign it to a variable or pass it into a method, the value will be unboxed and stored in a reference of the appropriate type.
Upvotes: 2