Reputation: 4696
I have some VB.NET (which I don't normally deal with) code which must be converted to C# (which I normally do).
The code happens to be in a Windows Forms app. I notice a couple of places such as:
Public Sub New()
ParentWindow = Me
where there is no ParentWindow variable defined, and it doesn't seem to be inherited here:
Public Class MainWindow
Inherits System.Windows.Forms.Form
Private Shared parentWindow As MainWindow
'....
(Though note that there is a similar variable with a lower-case first letter.)
and this:
DocumentCount = 0;
where, again, there is no corresponding variable definition and a straight conversion to C# Windows Forms indicates that there is no such member in the parent class.
Am I missing an import somewhere, or is this a feature peculiar to VB.NET that doesn't translate directly to C#?
Upvotes: 1
Views: 105
Reputation: 887453
VB is case insensitive, so it's actually assigning to parentWindow
and documentCount
.
(Edited in response to other comment)
Upvotes: 1
Reputation: 17845
VB is case insensitive. So parentWindow and ParentWindow may very well refer to the same variable. Usually the IDE fixes the case for you though...
Upvotes: 0
Reputation: 754725
If this is working it's likely that you have Option Explicit
set to off. This is a feature of VB.Net that allows for variables to be used before they are declared. Try adding the following to the top of the file
Option Explicit On
Upvotes: 3