vb.net - Hiding function on nested class -
public class class1 private names list(of string) private _class2 new class2 public sub addname(byval name string) names.add(name) _class2.add() end sub public readonly property addage(byval name string) class2 _class2.index = names.indexof(name) return _class2 end end property public sub clear() names.clear() _class2.clear() end sub public class class2 private _age list(of integer) protected friend index integer public property age() integer return _age(index) end set(byval value integer) _age(index) = value end set end property public sub add() _age.add(0) end sub public sub clear() _age.clear() end sub end class end class
how can hide ,sub clear , sub add on class2, they'll visible on class1, like;
public sub clear() names.clear() _class2.clear() '<<<<<<< end sub
i want not visible on sub main(), below.
sub main() dim person new class1 person.addage("kid").clear() '<<<<<< person.addage("kid").add() '<<<<<< end sub
if put protected, class1 cannot access it. if put protected friend, sub main() can still access them. , time.
used -hans passant- comment.
"trust in .net follows assembly boundaries. if 2 classes in 1 assembly there 2 programmers know how find each other if there's problem. way want put these classes in separate class library project. lets use friend. , whomever writes main method doesn't have friendly."
Comments
Post a Comment