It depends on what type of data was transmitted; in most cases, games use vector structures, intersection data, etc.
When data is a structure, you should avoid List<T> and pass on each value because the data is copied. But it depends a lot on the code, sometimes passing for a value can be faster, sometimes not. I would do some performance tests. You can use this method for simple tests without a profiler:
public static Int64 MeasureTime(Action myAction) { var stopWatch = new Stopwatch(); stopWatch.Start(); myAction(); stopWatch.Stop(); return stopWatch.ElapsedMilliseconds; }
When working with structures, you can always use out or ref .
Additional Information
All these situations may not cause performance problems, they simply explain the best practices that I learned when working with structures. To determine if ref and out are useful in each case, you should run a performance test.
ref used to prevent such situations:
Vector input = new Vector(x, y, z); input = ModifyVector(input); // This line causes copies of the input vector and it slow
The performance that falls here depends on the size of the Vector class, but it is not recommended to use the following method each time. When returning a simple Int32, it is not needed and should not be used to read code.
The right way:
Vector input = new Vector(x, y, z); ModifyVector(ref input);
Of course, the ref keyword can be used to speed up methods that return nothing, but these methods should take care of the data passed to them and avoid modifying them. In some situations, the speed advantage may be more than 50% (I have a high-performance vector library, and I checked many cases).
out used to prevent such situations:
Ray ray = ...; CollisionData data = CastRay(ref ray);
CollisionData contains at least the point where it hits the ground and normal. When using out here to get the result, it should be much faster.
The right way:
Ray ray = ...; CollisionData data; CastRay(ref ray, out data);
When using arrays.
.. you should know that the array is already a reference, and you do not need the ref or out keyword to process them. But when working with structures, you should know that you do not keep references to structures in your array. Therefore, by changing the value of the array, you can use ref myArray[0] to pass the value to the method and change the structure with a zero index without copying it. Also avoid creating new instances.