CuriOddities (part 2) [Kit George]
This week's Curioddity is a result of the way some things in the framework work. I think many of you are going to know the underlying issue here, so I'm going to make it a bit more obscure (not give too much help) to try to keep it interesting.
I would assert that the developer of the following code has a certain expectation about the code, but they've made an assumption about what happens when this code compiles (which will be wrong). The questions I have are 1) what is the expectation I'm alluding to (that's the game part!), and 2) do you think what the framework is doing 'behind the scenes' is the right behavior?
Reminder: If you're wondering what I'm getting at, I have made it slightly obscure, but the nature of the members is the key.
[Visual Basic]
Public Class KTC1
Public Shared Sub Foo()
End Sub
Public Shared Sub Bar()
End Sub
Public Shared Sub Zod()
End Sub
End Class
Comments
- Anonymous
August 13, 2004
My assumption is that the deveoper is assuming they have created, essentially, a singleton class as all the members are Shared (static). The framework behind the scenes (should that be compiler?) has created a public constructor so even though the members are all Shared there can be multiple instances of the class itself. - Anonymous
August 15, 2004
Kit,
Well, I am certainly confused. Give us more of a clue.
Seeya
Matthew - Anonymous
August 16, 2004
The comment has been removed - Anonymous
August 16, 2004
The comment has been removed - Anonymous
August 27, 2004
The comment has been removed