Modifying a procedural mesh using Lists is slow, what else can I use?

So I have a procedural mesh that I want to dynamically add vertices too every frame.

In Javascript I used Arrays to store my vertices/tris/normal/uvs.
Then in the update function I would rebuild my mesh every time (so clearing all those arrays) and then adding the new vertices to the mesh using Array.Add.

Now in C# there is no Array variable so I’m doing this.

List<Vector3> vertices = new List<Vector3>();
List<Vector3> normals = new List<Vector3>();
List<Vector2> uv = new List<Vector2>();
List<int> triangles = new List<int>();

And then I’m adding vertices using List.Add.

I’ve noticed that these lists are much much slower than what I was used to in Javascript using Arrays, so I was wondering if I could use some other method of storing the vertices instead of lists that would be better. The vertices array doesn’t have a fixed size because I’m adding more and more vertices on the fly.

Any help is greatly appreciated!

I highly doubt that the UnityScript “Array” class was faster than a generic List. The UnityScript.Lang.Array class used the untyped ArrayList class internally which works pretty much the same as the generic list class except that the ArrayList is untyped and has casting overhead.

You most likely use the Lists wrong. Do you reuse the list or do you recreate the lists every frame? Without seeing the code we can’t really help you- The generic list implementation uses strongly typed native arrays internally which is only recreated when it runs out of capacity. When you reuse the lists there should be almost no need to reallocate new arrays.

If you want further help you have to include the code you have trouble with.