C# Playyer Guidee Flashcards
What does the clamp function do?
If that value is lower than
the range, it produces the low end of the range. If that value is higher than the range, it
produces the high end of the range:
health += 10;
health = Math.Clamp(health, 0, 100); // Keep it in the interval 0 to 100.
MathF
The MathF class provides many of the same methods as Math but uses floats instead of
doubles. For example, Math’s Pow method expects doubles as inputs and returns a double
as a result. You can cast that result to a float, but MathF makes casting unnecessary:
float x = 3;
float xSquared = MathF.Pow(x, 2);
string username; // Declaring a variable
username = Console.ReadLine(); // Assigning a value to a variable
Console.WriteLine(“Hi “ + username); // Retrieving its current value
How is a variable declared?
A variable is declared by listing its type and its name together
string username;
What is an integer?
An integer is a whole number (no fractions or decimals) but either positive, negative, or zero.
-5, 1, 5, 8, 97, and 3,043
type concept
=
That = symbol means assignment, not equality.
Third, variable assignments are also expressions that evaluate to whatever the assigned value
was, which means you can assign the same thing to many variables all at once like this:
a = b = c = 10;
c = 10 is an expression
Is this an expresion?
c = 10 is an expression
c = 10 is an expression
Is this an expresion?
c = 10 is an expression