- Home /
Question by
nizameddinkale · Oct 01, 2020 at 05:32 PM ·
vector3listduplicatelinq
Remove duplicates vector y from vector3 list
List<Vector3> myList = new List<vector3>();
//Add some values to list
myList.Distinct();
this clears dublicates but how can i remove dublicate y values only?
Comment
Answer by xibanya · Oct 09, 2020 at 04:56 AM
add using System.Linq;
to the top of the file. Then where you need to remove the duplicate ys,
List<Vector3> distinctList = new List<Vector3>();
foreach (Vector3 v3 in myList)
{
if (!distinctList.Any(v => v.y == v3.y))
{
distinctList.Add(v3);
}
}
myList = distinctList;
Your answer
Follow this Question
Related Questions
Checking duplicate position in a list 1 Answer
LINQ Find String Duplicates in List 1 Answer
A node in a childnode? 1 Answer
C#, LINQ and Lists - help with 1 line of code? 1 Answer
How to Sync List 1 Answer