To put it simple, I want all the namespaces in the project recursively, and classes available in all namespaces found earlier.
var namespaces = assembly.GetTypes()
.Select(ns => ns.Namespace);
I am using this part earlier to get the namespaces in string format.
But now i got to know the underlying namespaces as well.
It sounds like you might want a
Lookupfrom namespace to class:Or alternatively (and very similarly) you could use
GroupBy:For example:
However, it’s not entirely clear whether that’s what you’re after. That will get you the classes in each namespace, but I don’t know whether that’s really what you’re looking for.
Two points to bear in mind:
If you really want to go from “Foo.Bar.Baz” to “Foo.Bar” and “Foo” then you can use something like: