This question already has an answer here:
How does one define a function that takes an optional array with an empty array as default?
public void DoSomething(int index, ushort[] array = new ushort[] {},
bool thirdParam = true)
results in:
Default parameter value for 'array' must be a compile-time constant.
Вы не можете создавать константы времени компиляции для ссылок на объекты.
Единственная допустимая константа времени компиляции, которую вы можете использовать, это null
, поэтому измените свой код на этот:
public void DoSomething(int index, ushort[] array = null,
bool thirdParam = true)
А внутри вашего метода сделайте следующее:
array = array ?? new ushort[0];