Question by 
               MurderousPotato · Aug 29, 2016 at 01:44 PM · 
                loopforeachif statementcomparesame  
              
 
              Compare a value to all other values in an array
Hey guys, I'm wondering if there's a way to compare a value in an array to all other values in an array.
An example of what I'm trying to do is as follows. I want to check to see if there are any duplicate coordinates assigned to a class object. Here's the kind of code I want to try to use, but everything I've tried so far has taxed the system too heavily.
 public class TestScript : MonoBehaviour {
 
 //As an example, I'll just use an integer array and integers.
 
 int[] testArray;
 int value
 
 void Start() {
   
   testArray = new int[2]
   value = random.Range(0, 1);
   testArray[1] = value;
   value = random.Range(0, 1);
   testArray[2] = value;
 
 }
 
 void TestFunction() {
   
   foreach(int value in testArray) 
     {
      /*
     I'm hoping there's some way to make an if statement (or something like 
     an if statement) comparing the instance of "value" being used to all
     other instances of "value" and activate if any other instances of value
     are the same (or at least something similar).
     */
     }
 
 }
 
 }
Thanks in advance! -Evan
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
how to check all elements in array 2 Answers
Comparing an ArrayList to the current object in an Arraylist being checked through a forEach Loop? 0 Answers
What to do for many comparison operations in foreach loop? 0 Answers
How can I check the color of GameObjects in an Array and print out their color? 0 Answers
Compare NavMeshSurfaces with each other 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                