How to access structures element using index

In reply to irshad_mansur123:

You can use a packed union to access a structure a number of different ways.

union packed { 
  struct packed {
    int a;
    int b;
    int c;
    int d; ..... till int z;
  } as_struct;
  bit [1:26] [31:0] as_array;
  } a2z;

Then a2z.as_struct.x and a2z.as_array[24] refer too the same set of 32-bits. Note that when you define an array, each element has to be the same type/width. In this case it only works if all members of packed struct are the same width.