¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: Setting a Simpl# Array Size based on a constant in Simpl+?


 
Edited

You can just call an "initialize" function of some sort and passing in your #DEFINE_CONSTANT identifier. Then in your C# you would have something like:
public void Initialize(int size) { array = new ???[size]; }
I've done this before when I know I only need an array of a max size (i.e. for I/O purposes for some functionality). The only difference here is that you need to ensure that the array is initialized so that it's not null if you go to use it before initialization, and you can't mark it as readonly either.

SIMPL+ can only call the parameterless constructor, you have no control over that. (Read the template comments when you first create a new SIMPL# Library.)

Arrays are fast since they are primitive, so if all you need is basic array features it should be fine to use an array. If you're developing a framework of some kind it is better to stick with encapsulation however. When instantiating a List<T>, it is good practice to set the initial capacity whenever possible to avoid unnecessary reallocations.
--
?
Crestron Service Provider - TBD Enterprises Inc.

Join [email protected] to automatically receive all group messages.