G
Guest
Class MyClas
Friend ReadOnly WithEvents MyObject as AnotherClas
..
End Clas
I have a VB.NET class that has a readonly object (i.e. It can only be assigned in the constructor). This enables me to safely expose it at friend scope without the possibility that it can be accidentally released or replaced. If however I want to handle its events I find that the compiler objects to the introduction of the WithEvents keyword. I tried to do the same thing in C# and it compiled fine, although I don't think C# doesn't support declarative event handlers. Does anyone know the reasoning behind these problems in VB.NET?
On a similar note why can't I specify a declarative event handler on a shared or module event?
Friend ReadOnly WithEvents MyObject as AnotherClas
..
End Clas
I have a VB.NET class that has a readonly object (i.e. It can only be assigned in the constructor). This enables me to safely expose it at friend scope without the possibility that it can be accidentally released or replaced. If however I want to handle its events I find that the compiler objects to the introduction of the WithEvents keyword. I tried to do the same thing in C# and it compiled fine, although I don't think C# doesn't support declarative event handlers. Does anyone know the reasoning behind these problems in VB.NET?
On a similar note why can't I specify a declarative event handler on a shared or module event?