I try to remove the duplicate names of the array using the for loop, but this is getting an error. I don’t know why?
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class ListManager : MonoBehaviour {
public string[] ListOfItems;
public int[] AmountOfItems;
private int ItemAmount;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
ItemAmount = SpawnItem.main.dropItem.Count;
ListOfItems = new string[ItemAmount];
for(int i = 0; i < SpawnItem.main.dropItem.Count; i++){
ListOfItems _= SpawnItem.main.dropItem*.Name;*_
* for(int x = 0; x < SpawnItem.main.dropItem.Count; x++){*
_ if(ListOfItems == ListOfItems[x]){
* ListOfItems.Remove(x);
}
}*_
* }*
* AmountOfItems = new int[ItemAmount];*
* for(int i = 0; i < SpawnItem.main.dropItem.Count; i++){*
AmountOfItems = SpawnItem.main.dropItem*.ItemID;*
* }*
* }*
}
The error says !
ListManager.cs(26,53): error CS1061: Type string[]' does not contain a definition for Remove’ and no extension method Remove' of type string[]’ could be found (are you missing a using directive or an assembly reference?)
Please Help :3
Is there a way to remove array with any command ?
– VrTechExNo, an array is fixed size. You can't reduce the number of slots. And can't just remove a slot at an arbitrary position. That is what List are for ;)
– JoyriderThank you Joyrider ! You are life saver :)
– VrTechEx