ahmet alp balkan ahmet alp balkan - 9 months ago 53
C# Question

Is C# namespace separator (.) defined somewhere?

Full name separator in C# is period character (

). e.g.

Is this defined somewhere like
, or is it hard coded in .NET reflection classes as well?

(e.g. is
implemented as
Type.Namespace + "." + Type.Name
assuming that it won't change?

Answer Source

Basically: the language specification. But actually, Type.FullName uses the BCL definitions, not the C# definitions - and interestingly they disagree. For example:

namespace X {
    public class Y {
        public class Z {}

To C#, Z is X.Y.Z; to the BCL it is X.Y+Z. The representation of generics changes too - with the BCL using back-ticks and numbers rather than angular brackets. I believe the BCL uses the CLI's format of types (which has a separate specification), but if you think about it: it is not required to do so (except for during reflection-emit).

AFAIK, these separators are not exposed via anything like Path.PathSeparator - but is, as you say, hard coded into the Type etc classes.