bool to true from a list comparison.

I have 2 int lists which i need to compare the values and see if they are all equal to one another if they are then i want to switch a bool to true otherwise i want that bool false.

Would anyone know the correct code to do this?

Elaboration –
i am using the 2 int lists to see if i have met costs for building resources
one list, currentResources and the other, requiredResources if all values in currentResources are equal to there counterparts within requiredResources i want my bool buildingCompleted to be true
if any one of these values is below there counterpart i want buildingCompleted to be false.
the way these are compared would be the same as their order so requiredResources[0] is compared to currentResources[0], tried searching but i can’t seem to word the question in a way that i find answers.
so if anyones has or knows where i can find one i’d be very greatful.

Considering you have two lists:

List<int> currentResources = new List<int>();
List<int> requiredResources = new List<int>();

Now you can call the following method to compare two lists for equality

bool areTheySame = AreListsSame(currentResources, requiredResources);

The method:

bool AreListsSame(List<int> list1, List<int>list2)
{
	// We start with the assumption that both the lists are same
	bool areSame = true;
	
	for(int i = 0; i < list1.Count; i++)
	{
		// If list2 does not contain any of the item from list1 then we set areSame to be false and return
		if(!list2.Contains(list1*))*
  •  {*
    
  •  	areSame = false;*
    
  •  	return areSame;*
    
  •  }*
    
  • }*
  • return areSame;*
    }