Remove Duplicated Objects in Array

Hi, I’m trying to compare all my LineRenderers with each other and see if there’re any dublicated LineRenderers with same values but this code destroys all:

public void RemoveDublicated () {
		//get all drawn lines
		LineRenderer[] lines = GameObject.FindObjectsOfType <LineRenderer>();
		
		for (var i = 0; i < lines.Length; i++) {
			var store = lines *.GetComponent <StoreLineRenderValues> ();*
  •  	//remove dublicated paintings*
    
  •  	if (i > 0) {*
    
  •  		for (var j = 0; j < lines.Length; j++) {*
    
  •  			var lastStore = lines [j].GetComponent <StoreLineRenderValues> ();*
    
  •  			if (store.theColor == lastStore.theColor && store.savedPos.Length == lastStore.savedPos.Length &&*
    
  •  				store.width == lastStore.width) {*
    
  •  				Destroy (store.gameObject);*
    
  •  				print (store.name + " Destroyed");*
    
  •  			}*
    
  •  		}*
    
  •  	}*
    
  •  }*
    
  • }*

Some one Helped me to fix it by checking each gameobject with previous one or next one:

By adding: for (var j = i + 1; j < lines.Length; j++) {

public void RemoveDublicated () {
		//get all drawning lines
		LineRenderer[] lines = GameObject.FindObjectsOfType <LineRenderer>();
		//loop
		for (var i = 0; i < lines.Length; i++) {
			var store = lines *.GetComponent <StoreLineRenderValues> ();*
  •  	//remove dublicated paintings*
    
  •  	if (store != null) {*
    
  •  		for (var j = i + 1; j < lines.Length; j++) {*
    
  •  			var lastStore = lines [j].GetComponent <StoreLineRenderValues> ();*
    
  •  			if (lastStore != null) {*
    
  •  				if (store.theColor == lastStore.theColor && store.savedPos.Length == lastStore.savedPos.Length &&*
    
  •  				    store.width == lastStore.width) {*
    
  •  					Destroy (store.gameObject);*
    
  •  					print (store.name + " Destroyed");*
    
  •  				}*
    
  •  			}*
    
  •  		}*
    
  •  	}*
    
  •  }*
    
  • }*