float arrays as arguments and float arrays with a specified length?

I want my function to have a parameter that takes a float array. What’s more is that I want the array to have a specified length so that when I pass it to a method it would have the correct number of arguments and not cause a CS1501 error.

This isn’t a question, It’s a list of things you want. What is preventing you from just passing into a function like:

int requiredLength = 3;
private void func(float[] arr) {
    if (arr.Length != requiredLength) throw new System.Exception("Wrong length");
    // do stuff here
}

if you want a function with some specific amount of floats passed, you obviously can just write that function with said amount of float parameters

private void func2(float a, float b, float c) {
    // do stuff
}

if you’re looking for the ability to pass a variable amount of floats into a function and process them like an array. You can do the following

private void funcWithSomeAmountOfParams(params float[] numbers)
{
    if (arr.Length != requiredLength) throw new System.Exception("Wrong length");
    foreach (float number in numbers)
        //do stuff here
}

Again, you didn’t ask a question, so I have no idea what you specifically need, but don’t see any reason why one of the above does not solve your problem, whatever that problem may be. CS1501 is for the incorrect amount of function parameters, so the actual size of the array is irrelevant, only the parameters passed to a function matters (and an array is one parameter).

@tayub121 Sorry I wasn’t actually clear. I was wondering if there was any way I could make the array in the parameter count as x number of arguments.

private void func1(float[] arr)
    {
        example.method(arr); //method needs 4 arguments but arr only counts as one
    }