Quantcast
Channel: Latest Questions by Monko
Viewing all articles
Browse latest Browse all 34

Find first empty "slot" in array

$
0
0
I am trying to make a function (in C#) that will return the first "empty" slot in an array. Lets pretend I have an array that looks like this: testarray[0] = Vector3(7,4,2); testarray[1] = Vector3(9,12,5); testarray[2] = Vector3(6,15,1); testarray[3] = Vector3(0,0,0); testarray[4] = Vector3(0,0,0); testarray[5] = Vector3(13,8,5); //... In this example, the function would return 3, because 3 is the first time testarray contains an "empty" Vector3. My attempts involve a for loop, but I still can't get it to work. Ill post my code so far, but if anyone has any other ideas, please help. int FindFirst(Vector3[] array) { for (int i = 0; i

Viewing all articles
Browse latest Browse all 34

Latest Images

Trending Articles





Latest Images