// Create an nsTArray of integers nsTArraymyArray; // Add elements to array myArray.AppendElement(5); myArray.AppendElement(10); myArray.AppendElement(15); // Get the length of the array int length = myArray.Length(); // length is now 3
// Create an nsTArray of strings nsTArrayIn this example, we create an nsTArray of strings (using nsCString), add elements to the array using AppendElement(), and then use .Length() to determine the number of elements in the array. Package/Library: Mozilla Firefox.myArray; // Add elements to array myArray.AppendElement("hello"); myArray.AppendElement("world"); myArray.AppendElement("!"); // Get the length of the array int length = myArray.Length(); // length is now 3