I'm really new to c# coming from c++ background I'm struggling to work with data structures in c++ I used to do that for example
struct product {
int weight;
double price;
} apple[10];
now the problem c# won't let me do the same because in c# when I declare an object type like apple I can't access the weight or the price now . is there a way to declare object type array ? like above I know I can do that
product apple = new product();
but I receive an error cannot apply indexing with [] to an expression of type Program.product . is there a way to apply indexing with data structures all I want to do is something like this .
struct product {
int x;
double w;
} array[10];
for (int i = 0 ; i < 5 ; i++ ){
array[i].x = array[i - 1].x
}
I appreciate your help.
structandclassin .NET is far more important than the difference between the two in C++. They use the same names but they are not the same concepts.