I have the following code below but haven't figured out how to implement the
var results =
section so that result[c] = valuesArray;
works properly?
var result = Array.CreateInstance(typeof(Array), dt.Columns.Count);
foreach (int c in Enumerable.Range(0, dt.Columns.Count))
{
// Create a list to hold values of the required type for the column
var valuesArray = Array.CreateInstance(typeof(float), dt.Rows.Count);
// Get the data to be written to the parquet stream
for (int r = 0; r < dt.Rows.Count; r++)
{
DataRow row = dt.Rows[r];
valuesArray.SetValue(row[c], r);
}
result[c] = valuesArray;
The error is:
Error: CS0021 = Cannot apply indexing with [] to an expression of type 'Array'
How do I instiate the Array
so it works?
Just as you set a value to valuesArray
with the SetValue()
method, you can do the same for result
:
result.SetValue(valuesArray, c);
If you need to retrieve the value during iteration, you can use result.GetValue(c)
:
foreach (int c in result)
{
var retrievedResult = result.GetValue(c);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With