I am currently using VB.NET and I ran into a problem. This is my class:
Public class foo
Private _bar As Integer
Private _name As String
Public Sub New(bar As Integer)
Me._bar = bar
Me._name = getName(bar) '//Passing in an argument where it is not needed
End Sub
Private Function getName() As String
'//Get name from database using _bar as a lookup(it essentially a primary key)
'//Name is obtained successfully (checked when debugging)
'//Return name
End Function
End Class
I can run this code even though I passed the getName argument, where it has no parameters. However, when I run it, the field Me._namealways ends with an empty string (and not a null value, since it initially starts with), but I know that the method getNamereturns the correct string when I checked it during debugging. If I delete an unnecessary parameter, it will work as expected, and Me._name will get the return value.
Why can I pass an argument where it should not be and not detect errors in my error list? I tried this on my colleagues computer, and they got the error "Too many arguments."