I was in interview and interviewer asked me the below question.
How to know what classes and methods are present in DLL ?
I was confused and said, "we can use tool or refactor that."
Can someone explain the different ways
to find everything from DLL (from code as well as from tools
)
I suspect the interviewer was referring to reflection. For example:
var assembly = ...; // e.g. typeof(SomeType).Assembly
var types = assembly.GetTypes();
var methods = types.SelectMany(type => type.GetMethods());
// etc
You'd need to filter the types using Type.IsClass
to get just the classes, for example. LINQ is very useful when working with reflection to query specific parts of a type or assembly. Note that the parameterless GetMethods()
call above will only return public methods; you can specify a BindingFlags
value to retrieve non-public methods as well.
See more on this question at Stackoverflow