Constructor in VB.Net

public class cons

dim a,b as integer

        public sub new() ''default constructor

            a=0

            b=0

            msgbox("a=+a.tostring()+"and b="+b.tostring())

       end sub

       public sub new(byval a as integer,byval b as integer) ''parameterized constructor

          me.a=a

          me.b=b

          msgbox("a=+a.tostring()+"and b="+b.tostring())

       end sub

       public sub display()

          consol.writeline("a={0} and b={1}",a,b)

       end sub

      protected overrides sub finalize() ''destructor

         a=0

         b=0

      end sub

end class

class demo

      inherits cons

      public sub new()

        mybas.new(12,23)

      end sub

end class

Module Modulecons

   sub main()

        Dim obj as new cons(10,20)

        obj.display()

        console.readline()

   end sub

end Module

 

 

 

 

 

 


Average Rating (0)
by Daniel   Gamit  in VB.Net  on 3/24/2015 1:23:13 AM  


Post Your Comment
*