This article is a mirror article of machine translation, please click here to jump to the original article.

View: 15879|Reply: 0

[Communication] C# typeof() example in detail

[Copy link]
Posted on 2/10/2019 1:03:00 PM | | |
What are the C# typeof() and GetType() areas?
1. The x in typeof(x) must be a specific class name, type name, etc., and cannot be a variable name.
2. The GetType() method inherits from Object, so any object in C# has a GetType() method, which has the same function as typeof(), returning the type of the current object of the Type type.
For example, there is such a variable i:
Int32 i = new Int32();
i.GetType() returns a value of type Int32, but you can't use typeof(i) because i is a variable, if you want to use typeof(), you can only: typeof(Int32), which returns the same type of Int32.
output
Methods:
Void SampleMethod()
System.Type GetType()
System.String ToString()
Boolean Equals(System.Object)
Int32 GetHashCode()
Members:
Void SampleMethod()
System.Type GetType()
System.String ToString()
Boolean Equals(System.Object)
Int32 GetHashCode()
Void .ctor()
Int32 sampleMember
output
Area = 28.2743338823081
The type is System.Double





Previous:New route 3 (newifi) original firmware plug-in complete
Next:c# Marshal.PtrToStructure
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com