"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Why Does VB.NET Have a Default Form Instance While C# Does Not?

Why Does VB.NET Have a Default Form Instance While C# Does Not?

Published on 2025-01-31
Browse:666

Why Does VB.NET Have a Default Form Instance While C# Does Not?
What is the fundamental difference between

VB.NET and C#window instances?

] In vb.net, there is a default instance in each window, while C#does not. This difference originated from different design concepts of different languages. VB.NET's (name)

attribute directly identifies the instance of the window class, while C#does not have the concept of this default instance.

default examples of vb.net: ] The default instance design of VB.NET is designed to facilitate programmers who have migrated from VB6. VB6 programmers are often difficult to distinguish the types and types of types and types.

There is no default instance in the default instance in the C#: C#emphasizes object -oriented principles and requires programmers to explicitly create instances. Unlike VB.NET, C#does not allow any attributes and methods to name the global name space. Therefore, C#does not provide a mechanism for defining the definition type default instance.

code example:

In C#, the formation and display of the window are explicit:

// The only way FORM1 FRM = New Form1 (); frm.show ();

In vb.net, it can be implicitly instantiated or explicitly instantiated:

'Common method one Form1.show () 'Common method 2 DIM FRM As New Form1 () FRM.SHOW ()

generated IL code generated:

// 唯一方法
Form1 frm = new Form1();
frm.Show();
form1

, and call

show ()
' 常用方法一
Form1.Show()

' 常用方法二
Dim frm As New Form1()
frm.Show()
method directly created by the

form1 directly created.

C#can it simulate the default instance? ] can simulate the default instance by using static attributes in the C#window class to simulate the default instance. However, this method is not elegant enough and requires additional model code. The reasons for designing differences: The design differences between VB.NET and C#reflect their respective target users. The default instance characteristics of VB.NET are designed to help programmers who move from VB6. C#focuses on object -oriented principles and encourages the instantiated classes, so that developers can better control the code.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3