ToBuildIn() Error ? Easy Answer ?

So I have this code to help me generate terrain:

Array CreateTerrainVertices(float[] _heightmap, float _resolution)
    {
        Debug.Log("Creating terrain vertices");
        // The minimum resolution is 1
        resolution = Mathf.Max(1, resolution);

        Array vertices = new Array();

        

        // For each point, in the heightmap, create a vertex for
        // the top and the bottom of the terrain.
        for (int i = 0; i < _heightmap.Length; i++) {
            
            vertices.Push(new Vector2(i / resolution, _heightmap*));*

vertices.Push(new Vector2(i / resolution, 0));
}

Debug.Log(“Created " + vertices.length + " terrain vertices”);
return vertices.ToBuiltin(Vector2) as Vector2[];
}
Everything works beyond perfect in this script! except that every last line!
return vertices.ToBuiltin(Vector2) as Vector2[];
I receive the error “Vector2 is a type, which is not valid in this context”.
But when I remove the the Vector2 making it look like:
return vertices.ToBuiltin() as Vector2[];
it tells me I need a type in the parameters… But looking at the first error I got it says “Vector2 is a type…”.
How can I fix this? What belongs there?

I think the codes are in Javascript, right? But it has some syntax errors… Maybe you can try the modified version as follows:

function CreateTerrainVertices(_heightmap : float[], _resolution : float) : Vector2[]
{
	Debug.Log("Creating terrain vertices");
	// The minimum resolution is 1
	resolution = Mathf.Max(1, resolution);

	var vertices = new Array();

	// For each point, in the heightmap, create a vertex for
	// the top and the bottom of the terrain.
	for (var i = 0; i < _heightmap.Length; i++) 
	{
		vertices.Push(new Vector2(i / resolution, _heightmap*));*
  •  vertices.Push(new Vector2(i / resolution, 0));*
    
  • }*

  • Debug.Log(“Created " + vertices.length + " terrain vertices”);*

  • return vertices.ToBuiltin(Vector2) as Vector2;*
    }