Let's say I have a Type
called type
.
I want to determine if I can do this with my type (without actually doing this to each type):
If type
is System.Windows.Point
then I could do this:
Point point1 = new Point();
However if type
is System.Environment
then this will not fly:
Environment environment1 = new Environment(); //wrong
So if I am iterating through every visible type in an assembly how do I skip all the types that will fail to create an instance like the second one? I'm kind of new to reflection so I'm not that great with the terminology yet. Hopefully what I'm trying to do here is pretty clear.