diff --git a/csharp/src/Apache.Arrow/Arrays/Decimal128Array.cs b/csharp/src/Apache.Arrow/Arrays/Decimal128Array.cs index 01724e2acda3e..0e3ec56740449 100644 --- a/csharp/src/Apache.Arrow/Arrays/Decimal128Array.cs +++ b/csharp/src/Apache.Arrow/Arrays/Decimal128Array.cs @@ -151,6 +151,30 @@ public Decimal128Array(ArrayData data) return DecimalUtility.GetDecimal(ValueBuffer, index, Scale, ByteWidth); } + public IList ToList(bool includeNulls = false) + { + var list = new List(Length); + + for (int i = 0; i < Length; i++) + { + decimal? value = GetValue(i); + + if (value.HasValue) + { + list.Add(value.Value); + } + else + { + if (includeNulls) + { + list.Add(null); + } + } + } + + return list; + } + public string GetString(int index) { if (IsNull(index)) diff --git a/csharp/src/Apache.Arrow/Arrays/Decimal256Array.cs b/csharp/src/Apache.Arrow/Arrays/Decimal256Array.cs index f314c2d6ebc9e..94a47f258280e 100644 --- a/csharp/src/Apache.Arrow/Arrays/Decimal256Array.cs +++ b/csharp/src/Apache.Arrow/Arrays/Decimal256Array.cs @@ -157,6 +157,30 @@ public Decimal256Array(ArrayData data) return DecimalUtility.GetDecimal(ValueBuffer, index, Scale, ByteWidth); } + public IList ToList(bool includeNulls = false) + { + var list = new List(Length); + + for (int i = 0; i < Length; i++) + { + decimal? value = GetValue(i); + + if (value.HasValue) + { + list.Add(value.Value); + } + else + { + if (includeNulls) + { + list.Add(null); + } + } + } + + return list; + } + public string GetString(int index) { if (IsNull(index))