Answers for "unity declare array"

C#
5

unity define array

int[] arr1 = new int[3]; 
 // Create an integer array with 3 elements
 var arr2 = new int[3]; 
 // Same thing, just with implicit declaration 
 var arr3 = new int[] { 1, 2, 3 };  
 // Creates an array with 3 elements and sets values.
Posted by: Guest on April-21-2021
7

unity array c#

string[ ] familyMembers = new string[]{"John", "Amanda", "Chris", "Amber"} ; 
 
string[ ] carsInTheGarage = new string[] {"VWPassat", "BMW"} ; 
 
int[ ] doorNumbersOnMyStreet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; 
 
GameObject[ ] carsInTheScene = GameObject.FindGameObjectsWithTag("car");
Posted by: Guest on April-12-2020
1

unity make a int arry with preset values

// For a preset arry in c#

var arr = new string[3] {"one", "two", "three"};

// Or you can do this:
 string[] arr = {"one", "two", "three"};
Posted by: Guest on January-06-2020

C# Answers by Framework

Browse Popular Code Answers by Language