Error passing class in method c#

I want to pass a variable with type class : “bpButtonID” in a method so the method will change the values of the variable.
Main code:

public static void check(bpButtonID id, int newID)
            {
                id[] array = new id[8];
                for (int i = 0; i < array.Length; ++i)
                {
                    array *= new bpButtonID(5);*

print(array*.GetID());*
array*.SetID(newID);//Put the new id*
print(array*.GetID());*
}
}
and then somewhere in the update i will call. this is just an example method so it doesnt really do something.
bpButtonID class:
private int id;
public ID(int id)
{
* this.id = id;*
* }*
* public int GetID(){*
* return this.id;*
* }*
* public void SetID(int id){*
* this.id = id; *
* }*
}
And i get an error (probably because of this line: “id[] array = new id[8];”)
because i dont know how to call it properly.
The error:
The type or namespace name `id’ could not be found. Are you missing a using directive or an assembly reference?

So because you say that it is an example code I’ll not dig into it then and just answer your question.

The error basically says that you can’t use Instance of your class to instantiate array of your class. And yes you got it right. To create properly your new array of your Class you should use class not its instance, like that:

bpButtonID[] array = new bpButtonID[8];

P.S. So in the comment below you say you have initialized class already and pass it to your check method like that:

check(myInitializedArray, someInt);

But then what you want to do with your class? That isn’t obvious from your code. Specify that.

For now I’ll just try to guess once more - you just forgot to initialize your bpButtonID as array? Then just initialize it as an array and pass as an array and change the value of it, you don’t need to create another array:

//make array:
bpButtonID[] mainArray;
//pass array:
check(mainArray, someInt);
//then do something with your array:
public static void check(bpButtonID[] id, int newID)
{
    for (int i = 0; i < id.Length; ++i)
    {
        id *= new bpButtonID(5);*

print(id*.GetID());*
id*.SetID(newID);*
print(id*.GetID());*
}
}
I’ll make the second guess, you want to pass array and clone it, then:
public static void check(bpButtonID[] id, int newID)
{
bpButtonID[] array = new bpButtonID[id.Length];
Array.Copy(id, array, id.Length);
for (int i = 0; i < array.Length; ++i)
{
array = new bpButtonID(5);
print(array*.GetID());*
array*.SetID(newID);//Put the new id*
print(array*.GetID());*
}
}
If in the end you’ll find out that those^ are still not what you want then just state clearly what you want…

Hi rhbrr5hrfgdfgw!
That error is usually caused by having a leak in a class. Check to make sure you have all your curly brackets.

Also, instead of using two separate functions to get and set the id, why not just use a property?

private int _id
public int ID
{
    get { return this._id; }
    set { this._id = value; }
}

You may already be aware of this and be doing that for a reason. In the case you aren’t, I hope you learned something.

I hoped this helped! Happy coding!

Well i kinda fixed it, so if anyone need to know:

Instead of calling the variable from the method parameters i did:

public bpButtonID[] bpArray;

And then i changed the length in the inspector to what i was needed, and then in the method:

bpArray *= new bpButtonID();*

So now i can get the values from the arrays.