There is a Default instance of form in VB.Net but not in C#, WHY?

Posted by Shekhar_Pro on Stack Overflow See other posts from Stack Overflow or by Shekhar_Pro
Published on 2011-01-15T07:41:28Z Indexed on 2011/01/15 7:54 UTC
Read the original article Hit count: 213

Filed under:
|
|
|
|

I'm just curious to know that there is The (Name) property, which represents the name of the Form class.This property is used within the namespace to uniquely identify the class that the Form is an instance of and, in the case of Visual Basic, is used to access the default instance of the form.

Now where this Default Instance come from, why can't C# have a equivalent method to this.

Also for example to show a form in C# we do something like this:

//Only method
Form1 frm = new Form1();
frm.Show();

But in VB.Net we have both ways to do it:

//'First common method (used slash because editor wouldn't format it properly)
Form1.Show();

//'Second method
Dim frm as New Form1();
frm.Show();

My question comes from this first method. What is this Form1, is it an instance of Form1 or the Form1 class itself. Now as i mentioned above the Form name is the Default instance in VB.Net. But we also know that Form1 is a class defined in Designer so how can the names be same for both the Instance and class name. If Form1 is Class then there is no (Static\Shared) method named Show(). So where does this method come from.

And finally why C# can't have an equivalent of this.

If there some mistake in my question Please let me know *I've checked this on stackoverflow, but couldn't find an answer to this.If you do find then please give a link to it.*

© Stack Overflow or respective owner

Related posts about c#

Related posts about vb.net