class - VB.net count the number of classes created in the namespace -


i'm trying learn bit using namespace, created 2 items using namespace. in future when implemented there x-number of items created using namespace.

how can count number of "cilinders" there exist?

public class form1      ' test using namespace     private sub button4_click(sender object, e eventargs) handles button4.click          ' create cilinder 1         dim cilinder_1 new body_namespace.body_cilinder         cilinder_1.index = 1         debug.print(cilinder_1.index)          ' create cilinder 2         dim cilinder_2 new body_namespace.body_cilinder         cilinder_2.index = 2         debug.print(cilinder_2.index)      end sub  end class  namespace body_namespace     class body_cilinder         private _index integer          public property index() integer                             index = _index             end             set(byval value integer)                 _index = value             end set         end property     end class end namespace 

after more digging found solution. using bad search term.

public class form1  ' test using namespace private sub button4_click(sender object, e eventargs) handles button4.click      ' create cilinder 1     dim cilinder_1 new body_namespace.body_cilinder     cilinder_1.index = 1     debug.print(cilinder_1.index)      ' create cilinder 2     dim cilinder_2 new body_namespace.body_cilinder     cilinder_2.index = 2     debug.print(cilinder_2.index)      ' count cilinders     debug.print(body_namespace.body_cilinder.count)  end sub  end class  namespace body_namespace  ' class defines cilinders properties easy access. class body_cilinder      ' counter determinate cilinder quantity required.     public shared count integer = 0      private _index integer     private _height double      ' cilinder index number integer finding position.     public property index() integer                     index = _index         end         set(byval value integer)             _index = value         end set     end property      ' cilinder height define cilinder height.     public property height() double                     height = _height         end         set(value double)             _height = value         end set     end property      ' add cilinder count every-time new "body cilinder" instance created     public sub new()         count = count + 1     end sub end class  end namespace 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -