Make an int/float all numbers between two numbers? (In a range)
Hello everyone! As the title says I'm curious as to how I could state a float as multiple numbers, or every number in a specific range, example being like every number between 1 and 500. Thanks!
Answer by Alanisaac · Jan 10, 2018 at 12:55 AM
You can't make a single float
into a range of numbers. A float
variable will store only a single floating-point number. What it sounds like you want is a list of floats.
Check out Enumerable.Range(int start, int count). That will get you a count
-sized enumeration of numbers starting from start
. Then if you'd like floats instead of ints, you can cast. The full code to do this is:
var numbers = Enumerable.Range(1, 500).Cast<float>().ToList();
Your answer
Follow this Question
Related Questions
Can you do float + float 1 Answer
How do I make an array with numbers between to values? 0 Answers
(26,47): error CS1525: Unexpected symbol `)' 1 Answer
[help] Array index is out of range 0 Answers
Any way to increase raycast range? 0 Answers