Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is C# namespace separator (.) defined somewhere?

Full name separator in C# is period character (.). e.g. System.Console.Write.

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

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

like image 427
ahmet alp balkan Avatar asked Feb 14 '13 07:02

ahmet alp balkan


People also ask

What is basic C language?

What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.

Is C -- a coding language?

C is a powerful general-purpose programming language. It can be used to develop software like operating systems, databases, compilers, and so on.

What is this C language?

C is an imperative procedural language supporting structured programming, lexical variable scope, and recursion, with a static type system. It was designed to be compiled to provide low-level access to memory and language constructs that map efficiently to machine instructions, all with minimal runtime support.

Is C same as C+?

While both C and C++ may sound similar, their features and usage are different. C is a procedural programming language and does not support objects and classes. C++ is an enhanced version of C programming with object-oriented programming support.


1 Answers

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.

like image 76
Marc Gravell Avatar answered Oct 18 '22 20:10

Marc Gravell