Tutorial by Topics: name



The nameof operator allows you to get the name of a variable, type or member in string form without hard-coding it as a literal.

The operation is evaluated at compile-time, which means that you can rename a referenced identifier, using an IDE's rename feature, and the name string will update with it.

Used to prevent name collisions when using multiple libraries, a namespace is a declarative prefix for functions, classes, types, etc.

The __name__ special variable is used to check whether a file has been imported as a module or not, and to identify a function, class, module object by their __name__ attribute.


Page 1 of 2