I'm using linq on a array and I need to find the index of the linq result. Is this possible? how?
My thanks in advanced.

This is my code:

Vector3[] vertices=mesh.vertices;

var V3=(from cur in vertices
        where (cur.x==point.PointX) && (cur.y==point.PointY)
        select cur).FirstOrDefault();

If it would be possible to change into a List, you would have an IndexOf method.
This is a simple example, that might give you a hint:

List<int> vertices = new List<int> { 1, 3, 5, 4, 9, 6 };

var V3 = (from cur in vertices
          where (cur == 5)
          select vertices.IndexOf(cur)).FirstOrDefault();

Here, V3 is equal to 2.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.