vb.net - Setting shared values in a for/next loop -


i have shared array needs calculation each index. right now, array initialized in new() , executes each time object created, redundant. how can set array initialized once, when created? static block in java?

i didn't include code because thought simple question. constructor called 64 times (working values of bits) , relevant code :

' decimal value of each bit public shared bitvalue(63) long  public sub new()     ' other non-relevant code here.      index = 0 63         bitvalue(index) = 1l << index     next end sub 

just in case wondering heck i'm doing, i'm rewriting java program did works casting , bitwise operators. part of learning vb, i'm working on translation. can idea of headed going http://sourceforge.net/projects/javabitwise/.

you can initialize right away

class test1      private shared _list new list(of string) {"1", "2"}  end class 

or in shared constructor

class test2      private shared _list list(of string)      shared sub new()         _list = new list(of string)         _list.add("1")         _list.add("2")     end sub  end class 

or check if value initialized or not in new

class test3      private shared _list list(of string)      public sub new()          ' use synclock         if _list nothing             _list = new list(of string)             _list.add("1")             _list.add("2")         end if      end sub  end class 

or put list in singleton


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -