- Home /
HOW TO ADD AND REMOVE VARIABLES ALREADY DECLARED IN A LIST
Explaining the situation: I have 3 raycasts that return the angle of the ground to me. What I would like to do, would be to store these values in a list to average them. However the average could only calculate the values of the raycasts that were in a collision, because if one of the three is not colliding and its value is 0, this would disturb the average, so in this case I would remove that value from the list to calculate the average.
Now that my question comes: there is a way that I can store the floats variables in the list, and not their values, and then I can add the value and calculate the average. So I could have a control to add and remove the variable I want to calculate the average. I thank anyone who can help me
Answer by Ikno_ · Sep 10, 2020 at 04:51 PM
RemoveAt(), and List. Clear() methods are used to delete items of a List in C#. RemoveAt() is what you’re looking for I think.