Pacrombie
❔ ✅ Reflection to get all Properties of a certain type
I have this in a class:
And this in the referenced Settings object:
The first block of code I sent does not compile because all the crap after the equals sign returns a list of objects, and I need a list of s. I've hardly ever used Reflection and I'm just a little lost. I know my code as it stands (if I were to change my list to a gets the values of all properties in my given class), but I just want the properties in a List. Any help would be appreciated. I'm starting to think it would just be better to have them in a Dictionary in my Settings class since the names of the properties do matter (I could use Dictionary keys). Anyways, thank u in advance :)
47 replies
❔ C# EventArgs
I'm starting to use System.EventHandler events and I'm just wondering if there is a point to the EventArgs class other than to be inherited for custom args? Like, I'm calling
StartEvent?.Invoke(this, new EventArgs());
and the new EventArgs()
just seems kind of pointless since its empty. Can I send something through the default EventArgs with a lambda expression or something?63 replies
❔ C# Fundamental: does setting one object to another point or copy?
this is probably a braindead question but in this code, is
anotherObject
"pointing" to someObject
(changing the instance variables of one will change the other's) or does anotherObject
copy the values of someObject
into a new object? im new to the language and trying to develop an understanding13 replies