My goal is to rename an instantiated array.
Below is a test case. The actual program I have reads data from an excel spread sheet, performs filtering and type conversion, and then stores that data in an array (e.g. the allData
array below).
Once the data is stored in the array I need to split the array into two copies of itself and perform a set of separate tasks on each of those copies.
To achieve this I created a clone (in the example arr1
). Now I have two copies of the same data (allData
and arr1
) but the term allData
, that was appropriately named in the past code, now feels inappropriately named, so I would like to rename it.
I considered creating another clone, but that would just leave the array (allData
) sitting there unused and needlessly taking up memory.
I also considered arr2 = allData
but that just leaves a reference (allData) sitting there needlessly. What I really want is to rename allData to arr2.
namespace nspace
{
public class c
{
public static void Main()
{
object[][] allData = new object[10][];
for (int i = 1; i <= 10; i++)
{
for (int j = 1; j <= 5; j++)
{
// fill array with something
}
}
arr1 = allData.clone();
// Rename array allData to arr2
}
}
}