What is the fundamental difference between the instance of VB.NET and the C#window?
VB.NET, each window has a default instance, while C#does not. This difference originated from different design concepts of different languages. VB.NET's attribute directly identifies the instance of the window class, while C#does not have the concept of this default instance.
The default instance of vb.net: (Name)
attributes allow them to directly access the default instance of the window. There is no default example in C#:
(Name)
C#emphasizes the object -oriented principle, 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 instance and display of the window are explicit:
In vb.net, it can be implicitly instantiated or explicitly instantiated:
generated IL code:
<code class="language-csharp">// 唯一方法 Form1 frm = new Form1(); frm.Show();</code>
instruction to instantiate the
class, and call the<code class="language-vb.net">' 常用方法一 Form1.Show() ' 常用方法二 Dim frm As New Form1() frm.Show()</code>
instructions, and directly call the method on the created instance.
C#can simulate the default instance? newobj
Form1
You 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. Show()
newobj
The reasons for design differences: Form1
Show()
The above is the detailed content of Why Does VB.NET Have a Default Form Instance While C# Does Not?. For more information, please follow other related articles on the PHP Chinese website!