Exportar (0) Imprimir
Expandir Tudo
Expandir Minimizar
Este artigo foi traduzido por máquina. Coloque o ponteiro do mouse sobre as frases do artigo para ver o texto original. Mais informações.
Tradução
Original

Type.Namespace Propriedade

Gets the namespace of the Type.

Namespace:  System
Assembly:  mscorlib (em mscorlib. dll)

public abstract string Namespace { get; }

Valor da propriedade

Tipo: System.String
The namespace of the Type, or null if the current instance represents a generic parameter.

Implementa

_Type.Namespace

A Namespace is a -tempo Naming convenience, Used mainly to define in an Aplicativo and organize classes and other Types in a single .From the viewpoint of the tempo de execução, There are no Namespaces.

If the current Type represents a constructed generic type, this property returns the namespace that contains the generic type definition.Similarly, if the current Type represents a generic parameter T, this property returns the namespace that contains the generic type definition that defines T.

If the current Type object represents a generic parameter, this property returns null.

This following example demonstrates a use of the Namespace and Module properties and the ToString method of Type.

using System;
namespace MyNamespace
{
    class MyClass
    {
    }
}
public class Type_ToString_3
{
    public static void Main()
    {
        try
        {
            Type myType = typeof(MyNamespace.MyClass);
            Console.WriteLine("\nPrinting the details of {0}.\n", myType); 
            // Get the namespace of the class Type_ToString_3.
            Console.WriteLine("Namespace: {0}.", myType.Namespace);
            // Get the name of the module.
            Console.WriteLine("Module: {0}.", myType.Module);
            // Get the fully qualified common language runtime namespace.
            Console.WriteLine("Fully qualified type: {0}.", myType.ToString());
        }
        catch(Exception e)
        {
            Console.WriteLine("Exception: " + e.Message ); 
        }
    }
}


package MyNamespace;

import System.*;

class MyClass
{
} //MyClass

public class Type_ToString_3
{
    public static void main(String[] args)
    {
        try {
            Type myType = MyNamespace.MyClass.class.ToType();
            Console.WriteLine("\nPrinting the details of {0}.\n", myType);

            // Get the namespace of the class Type_ToString_3.
            Console.WriteLine("Namespace: {0}.", myType.get_Namespace());

            // Get the name of the module.
            Console.WriteLine("Module: {0}.", myType.get_Module());

            // Get the fully qualified common language runtime namespace.
            Console.WriteLine("Fully qualified type: {0}.", myType.ToString());
        }
        catch (System.Exception e) {
            Console.WriteLine("Exception: " + e.get_Message());
        }
    } //main
} //Type_ToString_3


Contribuições da comunidade

ADICIONAR
Mostrar:
© 2015 Microsoft