Link to home
Create AccountLog in
Avatar of Silas2
Silas2

asked on

Anonymous Property

Say you have an anon method:
public string GetObjAndSetProp<T>(Func<T> makeNew, string newPropValue)
{
    T item = makeNew();
    item.MyCustomProperty = newPropValue; //how do you do this???
}

Open in new window

how do i set the MyCustomProperty value on the anon type T/item?
(I have multiple-objects with the same property name and i don't want to use an interface)
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Silas2
Silas2

ASKER

Interesting point 'Constraint', points me back to an interface. Suppose i could always fall back on reflection...
You certainly can use Reflection, but I wouldn't suspect it would be warranted in this particular case.