I'm fairly a beginner in C#.
Is it possible for me to declare local variables using local variables?
I want to generate 4 unique random numbers 0-100 without repeats, but now I'm stuck with these variables. I'm trying to declare these local variables using another local variable data, but I can't, because statements run from top to bottom. For example from the code below: I can't declare index1, because exclude1 hasn't been declared yet. If anyone can help me with this problem or suggest a new method, it would be greatly appreciated. Thanks!
var rand = new System.Random();
int index1 = rand.Next(0, 101 - exclude1.Count);
int index2 = rand.Next(0, 101 - exclude2.Count);
int index3 = rand.Next(0, 101 - exclude3.Count);
int index4 = rand.Next(0, 101 - exclude4.Count);
var exclude1 = new HashSet<double>() { index2, index3, index4 };
var exclude2 = new HashSet<double>() { index1, index3, index4 };
var exclude3 = new HashSet<double>() { index2, index1, index4 };
var exclude4 = new HashSet<double>() { index2, index3, index1 };