Home >Backend Development >C++ >VB.Net's Default Form Instance: Instance or Class, and How Does C# Compare?
VB.NET default window instance: The origin and C# comparison
In Visual Basic .NET, each window class contains a (name) property, which indicates its unique identifier in the name space. This attribute acts as the default instance of the window, which can be accessed by the window name itself.
Regarding the nature of Form1, it is an instance or the class itself, and this problem appears. In VB.NET, the default instance attribute is used, which is also manifested as the two. However, Form1 is mainly a class defined in the designer. The origin of the method
The show () method in form1 is not a static method. Instead, it is a hidden example method. Because VB.NET can add attributes and methods to the global name space, it can be accessed independently. This allows the code to use the class name to call the instance method.
Compared with these two methods (using Form1.Show () and FRM.SHOW ()), IL code compiled without obvious differences. Both methods will eventually call the instance show () method.
c# equivalent effect
C# lacks the direct equivalent of the vb.net default window instance. This decision comes from the emphasis of the programming of the object -oriented object of the C#, which needs to be instantiated by the object. However, C# developers can use the static attributes of instances in the window code to achieve similar mechanisms.Conclusion
Although the default window instance of the VB.NET provides a convenient brief way, it is important to understand the object -oriented principle of the underlying object and the limitations of such abstract. The method of C# emphasizes the separation of the class and the instance, thereby promoting a clear understanding of the program -oriented programming concept.
The above is the detailed content of VB.Net's Default Form Instance: Instance or Class, and How Does C# Compare?. For more information, please follow other related articles on the PHP Chinese website!