I started dabbling in Lua about a year ago and decided to learn C# instead when I recently discovered Unity!
All very exciting, but coming from an incredibly limited understanding of Lua, I'm really struggling with the concept of this:
// C# Random Number:
Random r = new Random();
r.Next(5, 10)
As far as I can recall, in Lua I would simply do this:
-- Lua Random Number:
r = math.random(5, 10)
My questions are:
In C#, why do I have to create an instance of this Random class? Why can't I just grab a random value and assign it to 'r' from the Random.Next(5, 10) method with similar syntax to the Lua example above? (I ask this because I don't have to create a new instance of the Console class to call the WriteLine method... that is why I'm confused at this point).
I have noticed that the IDE auto complete for Console shows: 'public static class' whereas for Random, it shows: 'public class'. If Console is 'static', is that the reason we don't need to create a 'new' instance?
I have read this: https://www.dotnetperls.com/static but the I'm missing some basic pieces of the puzzle, so still don't understand the concept fully.
I'm looking for help in understanding the concept, so please answer the questions with some examples (as if I'm a complete beginner).