Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

Dynamic Classes

$
0
0
I'm trying to figure out how to structure a large amount of data...

Here is a simple example:

Suppose I have up to 25 potential instances of objects (obj). Each of these objects has properties which I've created in the class (name, color, type).

example objects:

obj1
Banana
Yellow
Fruit

obj2
Lettuce
Green
Vegetable

obj2
Apple
Red
Fruit

I place these into a multidimensional array:


Is it considered bad practice to create each object in a loop? Or is there a better way to do this?

Code:

for x = 0 to 24
dim obj(x) as new myClass
obj(x).name = array(x)(0)
obj(x).color = array(x)(1)
obj(x).type = array(x)(2)


Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>