Vector3 vector = new Vector3(-1, 2, -3); Vector3 absVector = Vector3.Abs(vector); // absVector is (1, 2, 3)
Vector3[] vectors = new Vector3[] { new Vector3(-1, 2, -3), new Vector3(4,-5,6), new Vector3(-7,-8,9) }; foreach(Vector3 v in vectors) { Console.WriteLine(Vector3.Abs(v)); } // prints (1, 2, 3), (4, 5, 6), (7, 8, 9)This example uses an array of Vector3 structures and applies the Abs method to each one. It then prints out each resulting Vector3. The Vector3 Abs method is part of the System.Numerics package.