i have an array and want to create two classes that contains the reference of this array. When i change value of an element in array, i want to see the change in classes. The reason why i want to do that is i have a array of something and i have many classes that should contain or reach this array. How can i do that?
In C, i put the pointer of the array in existing structs and solve the problem but how can i do that in C#? There is no array pointer afaik.
int CommonArray[2] = {1, 2};
struct
{
int a;
int *CommonArray;
}S1;
struct
{
int b;
int *CommonArray;
}S2;
S1.CommonArray = &CommonArray[0];
S2.CommonArray = &CommonArray[0];
Thank you.
All arrays are reference types in C#, even if the element type of the array is a value type. So this will be fine: