✅ How to get values of list using reflection?
Recently I wrote some logic to get values from enum:
everything works good, I can work with
IEnumerable<T>
or just T
where T
is Enum
but now I need to get values from IEnumerable<string>
or string
:
List<string> str {get;set;} = new() {"a","b"};
so I wanna fill Jarray with a
and b
. How can I do it?
I apologize for the question posted. I'm just tired and not thinking straight6 Replies
foreach (var str in list)
what
all I have is type
i don’t understand. a type doesn’t have values
you need a list object
where else do the values in the list come from
ok, I will describe my task
I have property with custom attribute
so I need to get values from
Items
and add it to ["options"]
that's what I needis it always an IEnumerable<string>?
and
schemaItem
is this
, right?
so you would get the value of the property using reflection, then cast it to IEnumerable<string>, then do foreachhm I think I can't get value of property using reflection
I just have PropertyInfo