How can I print a continuous slice of a dynamic array?

In reply to ianmurph:

One way would be to use a string, and keep adding/concat-ing to it.


module test();
  logic [7:0] rx_message_array[];
  
  initial begin
    string s = "0x";
    rx_message_array = new[4];
    foreach(rx_message_array[i])
      rx_message_array[i] = i;

    foreach(rx_message_array[i])
      s = $sformatf("%s%X", s, rx_message_array[i]);
    
    $display("%s",s);
    
  end
endmodule