Answers for "array<>() in c#"

C#
3

How to make a array in c#

//use this for unity editor:
using UnityEngine;

public class MyScript : MonoBehaviour {
//You can change the variable type to int, float, strings and others
//Note: You need to asign the objects from the unity editor or the script
  
    public GameObject[] MyObjects;/*edit the size of the array in the unity editor
  								  or add = new GameObject[the length of the array]*/

    void Update(){
    //Here we are using for loop to destroy our objects in the list
        for (int i = 0; i < MyObjects.Length; i++){
            Destroy(MyObjects[i], 3.0f);/*The second parameter is how much seconds to wait 
            							before the certain object will be destroyed*/
        }
    }
}
//Sry for my english its bad
Posted by: Guest on June-09-2021
4

array in C#

// String array for my friends ( Example )
string[] myFriends = {"Friend1", "Friend2", "Friend3", "Friend4"};

// Display MyFriend2 at index of ( 1 )
Console.WriteLine(myFriends[1]);
Posted by: Guest on June-05-2021

Code answers related to "array<>() in c#"

C# Answers by Framework

Browse Popular Code Answers by Language