0

Hi C# experts out there

I have the following C# constructor which all have default values but I cannot figure out a way to set a meaningful default value for the double[] signal parameter:

public Raw(double amplitude = 10.0, ulong start = 0ul, ulong end = 10ul, double[] signal = null) : base(amplitude, start, end)
{
    if (signal == null)
    {
       this.Signal = new double[0];
    } else
    {
       this.Signal = signal;
    }
}

Is it even possible to use anything else besides null? What I actually want is an empty array like I do currently in the constructor's body. If I use new double[0] as default value the compiler complains that the parameter value must be compile-time constant. Any other approach to solve the above-shown scenario besides my current approach?

Thanks in advance for your support :)

tzwickl
  • 1,341
  • 2
  • 15
  • 31

0 Answers0