JerryWEC said:
Göran, thanks for the refer link!
I have created two classes on called WeldData and one called WeldInterval.
I have an array of WeldInterval's in my WeldData class.
I have not been able to test this because I'm in assembly /.dll hell again
right now.
I really just wanted to create a structure to hold my data and beable to
create empty records and build more data related records as needed. I have
490 bytes of data in a record and did not want to create a full blown class
or classes. I'm working in a manufacturing environment and speed is
everything. I'm hoping this will be fast enough for plant floor operation.
I'll provided more feedback if these two classes don't work as I expect them
too.
thanks! JerryM
Don't be afraid to create a class. If your data consists of strings,
then you are using objects anyway, so there is no real gain in using a
structure to handle them.
Objects are a lot faster in .NET than in VB6. I remember seeing a test
that showed that .NET handled objects about 100 times faster. Even if
that test might not be representative for all aspects of object use, you
get an idea of the difference in speed.
As the guidelines states, structures should only be used for data that
represent a single value. Also it says that a reasonable size for a
structure is 16 bytes. If you have 490 bytes in a structure, you will
get a performance hit everytime you use the structure. As it's passed by
value, all 490 bytes will be copied every time.
Also structures are value types, and that may cause you some problems.
If your WeldInterval is a structure and you access one of them from the
array, it will be copied. If you change a property in the structure you
might expect that you are changing the data in your array, but that
doesn't happen, as you are working with a copy of the data.