G
Guest
I am confused:
Question 1:
the online help for the Stack class reads:
Public Class Stack
Implements ICollection, IEnumerable, ICloneable
However the members of ICollection do not show up as members of Stack class.
Neither if I cast a Stack to ICollection.
How can I do this in my own class?
Question 2:
I implement an interface. that creates the skeleton code in my class.
I change the created scope from Public to Private:
Public Class Class1(Of T)
Implements ICollection(Of T)
Private Sub Add(ByVal item As T) Implements
System.Collections.Generic.ICollection(Of T).Add
End Sub
Casting an object of this class to the implemented interface still lets me
use the private method from another assembly:
Dim x As New PowerLib.Class1(Of Integer)
CType(x, ICollection(Of Integer)).Add(2)
Imho narrowing the scope should always work, the Add() method should not be
accessible.
I want to implement my own generic collections which need parts of
ICollection.
thank you very much. herbert
Question 1:
the online help for the Stack class reads:
Public Class Stack
Implements ICollection, IEnumerable, ICloneable
However the members of ICollection do not show up as members of Stack class.
Neither if I cast a Stack to ICollection.
How can I do this in my own class?
Question 2:
I implement an interface. that creates the skeleton code in my class.
I change the created scope from Public to Private:
Public Class Class1(Of T)
Implements ICollection(Of T)
Private Sub Add(ByVal item As T) Implements
System.Collections.Generic.ICollection(Of T).Add
End Sub
Casting an object of this class to the implemented interface still lets me
use the private method from another assembly:
Dim x As New PowerLib.Class1(Of Integer)
CType(x, ICollection(Of Integer)).Add(2)
Imho narrowing the scope should always work, the Add() method should not be
accessible.
I want to implement my own generic collections which need parts of
ICollection.
thank you very much. herbert