If I have a class called MyProgram, is there a way of retrieving “MyProgram” as a string? 1Best Answer 11 Try this: this.GetType().Name
How can I achieve this? public class GenericClass<T> { public Type getMyType() { //How do I return the type of T? } } Everything I have tried so far...
How can I check whether a variable is defined in Ruby? Is there an isset-type method available? 15 s 15 Use the defined? keyword (documentation). It will return a...
Is it possible to find all classes or interfaces in a given package? (Quickly looking at e.g. Package, it would seem like no.) 29 s 29 Due to the...
Using reflection, how can I get all types that implement an interface with C# 3.0/.NET 3.5 with the least code, and minimizing iterations? This is what I want to...
Does reflection in C# offer a way to determine if some given System.Type type models some interface? public interface IMyInterface {} public class MyType : IMyInterface {} // should...
How do I get a list of all the properties of a class? 1Best Answer 11 Reflection; for an instance: obj.GetType().GetProperties(); for a type: typeof(Foo).GetProperties(); for example: class Foo...
If I have two variables: Object obj; String methodName = "getName"; Without knowing the class of obj, how can I call the method identified by methodName on it? The...
One may not always know the Type of an object at compile-time, but may need to create an instance of the Type. How do you get a new object...
Is there a way to get the path for the assembly in which the current code resides? I do not want the path of the calling assembly, just the...