PrepAway - Latest Free Exam Questions & Answers

How should you complete the code?

DRAG DROP
You write the following code.

You need to get the list of all the types defined in the assembly that is being executed currently.
How should you complete the code? To answer, drag the appropriate code elements to the correct targets in
the answer area. Each code element may be used once, more than once, or not at all. You may need to drag
the split bar between panes or scroll to view content.
Select and Place:

PrepAway - Latest Free Exam Questions & Answers

Answer:

Explanation:
The AppDomain.CurrentDomain.GetAssemblies() gives you all assemblies loaded in the current application
domain.
The Assembly class provides a GetTypes() method to retrieve all types within that particular assembly.
Example: Using Linq:
IEnumerable<Type> types =
from a in AppDomain.CurrentDomain.GetAssemblies()
from t in a.GetTypes()
select t;
http://stackoverflow.com/questions/4692340/find-types-in-all-assemblies

6 Comments on “How should you complete the code?

  1. Seamus says:

    public class Question12
    {
    public void GetAllAssembles()
    {

    List assemblies = AppDomain.CurrentDomain.GetAssemblies()
    .SelectMany(x => x.GetTypes())
    .Where(x=> x.IsClass && (x.Assembly == this.GetType().Assembly)).ToList();
    foreach(Type type in assemblies)
    {
    Console.WriteLine(type.Assembly.FullName);
    }
    }
    }




    2



    0

Leave a Reply