vb.net - Dynamic creation of class instances -


is there way create class instances on fly , refer them later? have class various methods , properties designed hold & calculate product data. i'd application able handle many individual products user needs. code won't work should give idea of i'm asking:

for x = 1 howevermany      dim product_ & x.tostring() new myproductclass  next x 

i appreciate may not best approach (i should use lists or arrays hold product data) i'm curious whether possible technical standpoint. i'm using vb.net answers in .net language welcome. thanks.

store them in list(of t). can linq 1 or more objects in list.

'class level private products new list(of myproductclass)  'place load them x integer = 1 howevermany   dim myc new myproductclass   mpc.id = x   'set other properties needed   products.add(mpc) next 

get 1 it's id:

dim mpc4 = (from p in products p.id = 4).firstordefault if not mpc4 nothing   'object exists end if 

you can make other similar queries on list well.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -