18 Replies
'Get' how?
like
private Dictionary<string, ContentDefinition> _definitions;
This can be achieved by using reflection (however, fields are made private for a reason, so think about your code a little more before using it)
^^ how can i acces with reflection?
Firstly, why do you want this?
It's almost always a bad idea
for a register system
Unless of course the private field is in the same class
Do you own the class that the field is in?
no
right
Wdym by "a register system"?
its a very complex thing
but i try to acces to the list
and add my stuff to it
you probably shouldn't add stuff to a private list
the owner of the framework just not thought about it
and he is not at home
so i need to find a temporary way
Well, you can use
typeof(TheClass).GetField("nameOfField", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(instanceOfClass)
and how can i add now things to the list?
i mean it does not work with the list
wdym?
You get the value of the field as an
object
, then you have to cast that to the appropriate typeUnknown User•2y ago
Message Not Public
Sign In & Join Server To View
they don't own the class
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.