I am from a c# background and am converting a vb.net windows forms app to c#. I have a windows form called associateForm. In code the developer references associate form like so:-
Private Sub NotifyIcon1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles EMS.MouseDoubleClick If e.Button = Windows.Forms.MouseButtons.Left Then If associateForm.WindowState = FormWindowState.Normal And associateForm.Visible = True Then associateForm.WindowState = FormWindowState.Minimized Else associateForm.WindowState = FormWindowState.Normal End If associateForm.Show() associateForm.Focus() 'bring to front of other windows associateForm.Activate() End If End Sub
But the thing is that associateForm is not instantiated within the class where the method is being executed. Nor is the class static. Nor does there seem to be an instance of the class anywhere in code. Can anyone shine any light on why this seems to work but when i try this in C# it is not having any of it.
VB.Net for .Net 2.0 and later has something called default form instances. When you define a form, you get an automatic instance of the form with the same name as the type.