using System; using System.Numerics; class Program { static void Main() { Vector3 vector = new Vector3(3, 4, 5); float length = vector.Length(); // length = 7.071068f Console.WriteLine("The length of the vector is: " + length); } }
using System; using System.Numerics; class Program { static void Main() { Vector3 vector = new Vector3(2, 2, 0); Vector3 normalized = Vector3.Normalize(vector); Console.WriteLine("The normalized vector is: " + normalized); float length = normalized.Length(); // length = 1.0f Console.WriteLine("The length of the normalized vector is: " + length); } }In this example, we first create a vector with components (2, 2, 0). We then call the Vector3.Normalize method to create a new vector with the same direction but a length of 1. Finally, we use the Length method to confirm that the length of the normalized vector is indeed 1.0.