Converting from js to c#

Hi, I have an old script that I want to convert to c#, but I’m getting errors, you can find the original script here: Select randomly x arrays and instantiate them - Unity Answers

I tried converting, this is what I have done so far, and now I don’t know how to fix the errors it has.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class BrickGenerator : MonoBehaviour {

	public int bricksToSpawn = 85;
	public GameObject[] bricks;
	List<GameObject> bricksListmeObject = new List<GameObject>(); // declare a new list

	void Start() {
		PopulateBricksList();
		ChooseRandomBricks();
	}
	
	
	void PopulateBricksList() {
		// declare a new list
		List<GameObject> bricksList = new List<GameObject>();
		
		// get the length of the built-in array
		int totalBricks = bricks.Length;
		
		// add each brick to the brickList
		for (int i = 0; i < totalBricks; i++){
			bricksList.Add(bricks*);*
  •  }*
    
  • }*

  • void ChooseRandomBricks() {*

  •  // choose a brick from the bricksList*
    
  •  for (int i = 0; i < bricksToSpawn; i++ ){*
    
  •  	// find the current length of the bricksList*
    
  •  	int bricksRemaining = bricksList.Count;*
    
  •  	// get a random number*
    
  •  	int rndChoice = Random.Range(0, bricksRemaining - 1);*
    
  •  	// instantiate that chosen brick*
    
  •  	Instantiate(bricksList[rndChoice], brickList[rndChoice].transform.position, transform.rotation);*
    
  •  	// remove that brick from the list*
    
  •  	bricksList.RemoveAt(rndChoice);*
    
  •  }*
    
  • }*
    }
    Here are the erros: Dropbox - Captura de tela 2014-04-06 16.21.50.png - Simplify your life
    Thanks in advance.

You declared bricksList inside PopulateBricks(), so it can only be called within that context; you could move it to the top/generic variable declare area.