I have an int[] building; that I want to instantiate dynamically based on another array int[] info;
The info will hold int ranging from 0-48
To build the building array.. If there is a non-zero value in the info array at index ind I want to add that index to the building array.
So if info looks like this {0, 12, 24, 48} I'd like building to show {1, 2, 3} another example {12, 0, 0, 48} -> {0, 3}
Is there a neat one liner to accomplish this?
How I have been doing it
int[] info = new int[]{12, 0, 0, 48};
List<int> indxs = new List<int>();
for (int i = 0; i < info.Length; i++)
if (info [i] > 0)
indxs.Add(i);
int[] building = indxs.ToArray();
IndexesWhere, similar toSystem.Linq.Enumerable.Where.