C # and VB.net have some and type-related methods and keywords, beginners just start to understand may be a little confusing, here to tidy up, hoping to help beginners. If you have something to add, you are welcome to reply.
1.GetType
(1) Object.GetType ()
This method is a method for all objects, and the explanation in MSDN is "get the Type of the current instance." ”。 The return value of the method is an instance of the System.Type type, representing the exact run-time type of the current instance.
For example:
C#:
int number = 3;
System.Type t = number.GetType();
Console.WriteLine(t.FullName); //输出:System.Int32
VB.net:
Dim number as Integer = 3
Dim t As System.Type = number.GetType()
Console.WriteLine(t.FullName) '输出:System.Int32
(2) Vb. GetType method in net
Refer to the explanation in MSDN: Returns a type object of the specified types. Type objects provide information about types, such as properties of types, methods, and events.
Usage: GetType (TypeName), where TypeName is the name of the type that needs to get its information.
For example:
Dim t As System.Type = GetType(Integer)
Console.WriteLine(t.FullName) '输出:System.Int32
(3) Type.GetType Series Method
There are 4 GetType methods in the System.Type type, where the GetType () with no parameters is an instance method that inherits from object, and the other three are static methods (C # is static, VB.) NET is shared). The example method does not need to introduce, is Object.GetType (). A static method is to get System.Type by a string of type names. The explanation in MSDN has one big piece, and here's a simple example:
C#:
System.Type t = Type.GetType("System.Int32");
Console.WriteLine(t.FullName); //输出:System.Int32
vb.net
Dim t As System.Type = Type.GetType("System.Int32");
Console.WriteLine(t.FullName) '输出:System.Int32
Note that the type name here must be the full name of the containing namespace, that is, the System.Type fullname, not the type name in C # or vb.net, such as "int" in C # or "Integer" in vb.net