int _viewMatricesStartIndex;
int _projectionMatricesStartIndex;
int _worldMatricesStartIndex;
Matrix4x4[] _matrices;
public ref Matrix4x4 GetMatrix(MatrixType type, int offset) {
switch (type) {
case MatrixType.ViewMatrix:
return ref _matrices[_viewMatricesStartIndex + offset];
case MatrixType.ProjectionMatrix:
return ref _matrices[_projectionMatricesStartIndex + offset];
case MatrixType.WorldMatrix:
return ref _matrices[_worldMatricesStartIndex + offset];
default:
throw new ArgumentOutOfRangeException(nameof(type));
}
}
Code snippet taken from "Complete C# Quick Reference - C# 7".