mardi 25 février 2020

C# Object Property to Load Values from List

I have a class with a property: public object something { get; set; }

I obtain a list of values from a method, say List<string> myList and I would like to load each value into property something without using expando etc.

Basically, I am trying to to:

SomePrototypeClass myClass = new SomePrototypeClass();

foreach (string item in myList)
{
myClass.something.Add (item)
}

Is this possible? (Reflection or somehow?) Could anyone advise please?





Aucun commentaire:

Enregistrer un commentaire