[You must know. NET] The 28th time: Talk about the name of this thing

Source: Internet
Author: User

1 origin

Lao Zhao is talking about the cache of expression trees (2): It is mentioned in the expression tree generation string that discussing FullName or AssemblyQualifiedName providing complete type information when describing type information is a small topic, but it is a topic worth talking about. The following three properties for reacting to a type name information in. NET are:

Name to get the names of the current members.

FullName, gets the fully qualified name of type, including the namespace of type, but does not include the assembly.

AssemblyQualifiedName, gets the assembly-qualified name of type, including the name of the assembly from which the type is loaded. In fact, AssemblyQualifiedName is defined as a read-only abstract attribute, and the specific implementation is implemented by its derived classes, such as TypeBuilder, which we can have a general idea of by its specific implementation type.

The definition here is undoubtedly official (MSDN), as the saying goes, the truth is the only criterion for testing truth, then these three similar concepts, what is the difference, we return to the facts.

2 Cheong Chat Name

2.1 By the simple start

From the simple start, we might as well look at the facts returned by the three different name of object:

static void Main(string[] args)
{
   Type t1 = typeof(object);
   Console.WriteLine(t1.Name);
   Console.WriteLine(t1.FullName);
   Console.WriteLine(t1.AssemblyQualifiedName);
}

What about the execution results?

As MSDN says, name returns a simple type name, FullName contains namespaces, and AssemblyQualifiedName contains assembly full names. For a assemblyqualifiedname assembly, however, the associated assembly information is still returned, for example:

Console.WriteLine(t3.AssemblyQualifiedName);

Anytao.Learning.ExpressionTree.One, Anytao.Learning.ExpressionTree, version=1.0.

0.0, culture=neutral, publickeytoken=null

2.2 to the complex over

If we just look at the simple type, then the three guys are not worth the time to notice, except for simplicity and complexity. So, I took the expression to Sanding in particular:

static void Main(string[] args)
{
   Type t2 = typeof(Expression<Func<int, int>>);
   Console.WriteLine(t2.Name);
   Console.WriteLine(t2.FullName);
   Console.WriteLine(t2.AssemblyQualifiedName);
}

What about the results of the execution?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.