hugi
child/parent class, how do i 'mass define' child properties?
So I have a class
public class Parent: child {
public IEnumerable<AdditionalProp> MoreStuff { get; set; }
}
public child {
public int age { get; set; }
public string name{ get; set; }
public int score{ get; set; }
.... (many more)
}
something like that...
so if I have a value of
Child a = data.getChild();
IEnumerable<AdditionalProp> b = data.getMoreStuff();
how do I make it so that I can put both into the Parent class without retrieving and setting the child variables (age, name etc.) separately?
(without Automapper)
8 replies
How do I cast my enum to a list of custom object?
(yes I am aware of dictionary, but I want to use custom object in this case)
When I did it to dictionary I was doing the following:
var dict = Enum.GetValues(typeof(T))
.Cast<T>().ToDictionary(t => (int)(object)t, t => getEnumString(t.ToString()));
But I wasn't able to figure out how to change that to cast to custom object instead, or do I just convert the dict above into custom object after? Is there a way to not do that?
custom object myObject: id: number, value: string11 replies