PPSz
✅ confused about classes
I learned C# from older version of this one: https://www.youtube.com/watch?v=0QUgvfuKvWU it's a little older but basics are still the same
204 replies
✅ confused about classes
ok, maybe to make things less confusing as there are different words for same thing:
field
, variable
, parameter
, argument
are almost the same thing but they are called differently in different places. Just a container to store value of certain type
type
, class
, blueprint
is more or less also the same
method
, function
, action
is just a block of code inside { }
that does some logic204 replies
✅ confused about classes
here's an example:
class Car
has one field (variable) that's maxSpeed
, which is unique for every car we create in this example. If you invoke Drive()
method on car1
or car2
we get different results.
What you can get confused on when comparing this to Random
class is Next()
method in random class returns a random number instead of predefined variable (that's why the class is called Random
). You might ask why you need to create an instance of this object (line Random numberGenerator = new Random()
), it's because you can give this instance a seed for example: Random numberGenerator = new Random(12345)
. That means if you do:
you'll get three random numbers but they will be always the same between program runs. Computers just calculate list of random numbers based on the seed (if you do new Random()
the seed is also random). It's like seed in Minecraft, where worlds are randomly generated but you can give the game a seed and you'll get always the same world204 replies