Reputation: 5834
I'm trying to convert the following (shortened for readability) to C# and running into problems
#define DISTMAX 10
struct Distort {
int a_order;
double a[DISTMAX][DISTMAX];
};
I thought in structs it was a simple case of using "fixed" however I'm still getting problems.
Here's what I've got (With a define higher up the page):
const int DISTMAX = 10;
struct Distort
{
int a_order;
fixed double a[DISTMAX,DISTMAX];
}
The error I get is stimply Syntax error that ] and [ are expected due to what I expect to be a limitation of a single dimension array.
Is there a way around this?
Upvotes: 5
Views: 3535
Reputation: 1503290
Fixed sized buffers can only be one-dimensional. You'll need to use:
unsafe struct Distort
{
int a_order;
fixed double a[DISTMAX * DISTMAX];
}
and then do appropriate arithmetic to get at individual values.
Upvotes: 7