How to print float items added inside a list

Hello everyone,

I’m totally new to coding and C# and I got stuck in a problem.
I’m developing a test in Unity in which I need to save and print a list of reaction times. I have a cube who is moving towards the player. When the cubes enters an audiotrigger a sound is played. Then the player needs to press “S” and his reaction time is stored in a public List.
What I am trying to do is to print all the elements of the list. At the bottom, I tried to use the foreach function but in this way the Console never stops to print the values in the list, while I need them to be printed only once.

At the moment I am trying to understand how to do this, but the final goal it would be to have something similar to this:
// Debug.Log → Reaction Time + index number of the list + = value of the reaction time OR 10 if RT > 2
I chose 10 to be an indicator of a “missed reaction time” which is important to me for further analysis.

May I ask you for your help?

Thank you very much

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ReactionTime : MonoBehaviour {

private bool isTiming = false;
private float timeTillKeyisPressed = 0;
public List <float> reactionTimes = new List<float>();

void OnTriggerEnter(Collider other)
	if (other.gameObject.CompareTag ("AudioTrigger"))
		isTiming = true;
// Update is called once per frame
void Update () 
	if (isTiming)
		timeTillKeyisPressed += Time.deltaTime;

	if (isTiming && Input.GetKeyDown(KeyCode.S) || timeTillKeyisPressed >= 2f)
		reactionTimes.Add (timeTillKeyisPressed);
		isTiming = false;
		timeTillKeyisPressed = 0; 

	foreach (float item in reactionTimes)
			Debug.Log (item); 


forloop over foreach i think


for(int i = 0; i < reactionTimes.Count; i++) { Debug.Log("Item value: " + reactionTimes*);* *}* **

Thank you for answering @zereda-games !

I’ve tried with your script and it works. The only thing is that for every new item in the list it prints me the whole list from the start, which I find quite redundant. But maybe it is something someone would prefer or that is more correct!

I’ve tried to write a condition to print the whole list (pretty redundant too). This writes me the whole list only once but only if it is completed, which might not be the best thing to do. Plus, I think there might be a smarter way to write the Debug.Logs, instead of writing 7 of them.

if (reactionTimes.Count == 7)

			Debug.Log ("ReactionTime1 = " + reactionTimes [0]);
			Debug.Log ("ReactionTime2 = " + reactionTimes [1]);
			Debug.Log ("ReactionTime3 = " + reactionTimes [2]);
			Debug.Log ("ReactionTime4 = " + reactionTimes [3]);
			Debug.Log ("ReactionTime5 = " + reactionTimes [4]);
			Debug.Log ("ReactionTime6 = " + reactionTimes [5]);
			Debug.Log ("ReactionTime7 = " + reactionTimes [6]);

These might be stupid details but I’m really interested in thinking “smart” while coding.