I am new to C#, normally a C programmer so I'm having trouble figuring out the best method to use. Hopefully I can get some advice to help me decide.
I have a structure that looks like this (I did this how I would do it in C):
struct structData
{
long type;
long myArray[50];
string text;
}
I create an array of these struct's that I can continually read/write to globally/publicly. (I will need to store the data in there so it can be accessed at a later time)
structData arrayOfStructs[50];
The goal would be to access the data like this:
arrayOfStructs[0].type = 123;
arrayOfStructs[0].myArray[0] = 456;
When I try to implement this in C# I get a variety of errors:
"myArray
" needs to fixed to 50, but it needs to be in unsafe area
If I try to initialize it "... = new ...
" I get an error
First, should I be using List<> instead of arrays? Is there a performance difference?
Second, should I create a class instead of a structure, initialize the array in a constructor, then create a list/array of the objects? How would you implement this?
And yes I need to use longs.