mercredi 29 avril 2015

How to get all namespace in project by assembly? [duplicate]

This question already has an answer here:

I want get all namespace in main project by method assembly.(Not all aseembly)

I read below question but not useful.

Getting all types in a namespace via reflection

for example

class in Assembly:

namespace test
{
    public class Class1
    {
        public string[] AllNameSpace()
        {
            return Assembly.GetExecutingAssembly().GetTypes().Select(x => x.Namespace).ToArray();
        }
    }
}

code in main project:

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var util=new Class1();
            Console.WriteLine(string.Join(",",util.AllNameSpace()));//return test
            Console.ReadKey();
        }
    }
}

return "test" But I want contain ConsoleApplication1 namespace.





Aucun commentaire:

Enregistrer un commentaire