Codecademy C# Flashcards
Command to print text to a console
Console.WriteLine(“”)
Command to read text a user types into the console
Console.ReadLine()
Command to run interactive code
dotnet run
One line comments
after //
Multi-line comments
between /* and */
Whole integer number data type
int
A piece of text data type
string
Data type which represents the logical idea of true or false
bool
Decimal number data types
double
Single characters data type
char
Assign variable command
data type __________ = “__________”;
Assign variable example
string countryName = “Netherlands”
Good practice style for naming variables
camelCase
camelCase example
string iAmAVariable
Implicit conversion definition
Happens automatically if no data will be lost in the conversion
Explicit conversion definition
Requires a cast operator to convert a data type into another one
Explicit method for converting to string
Convert.ToString()
Explicit method for converting to double
Convert.ToDouble()
Character after decimal to show that it’s a decimal
m
Character after decimal to show that it’s a decimal example
decimal variableName = 489872.76m
Command to increment by one
++
Command to decrease by one
- -
Modulo definition
Returns a remainder
Modulo operator
%
Command too find the absolute value of a number
Math.Abs()
Command to find the square root of a number
Math.Sqrt()
Command to round a given double or decimal down to the nearest whole number
Math.Floor()
Command to return the smaller of two numbers
Math.Min()
Not a number abbreviation
NaN
Command to raise an exponent
Math.Pow( , )
Command to round a double or decimal up
Math.Ceiling()
Command to find the larger of two numbers
Math.Max()
Character to escape a character
\
Command to print the following text on a new line
\n
String concatenation symbol
+
String interpolation definition
A method for inserting variable values in the middle of a string
String interpolation command
$“{}”
String interpolation example
$”Your favorite musician is {yourFaveMusician}.”
Command to find how many characters exist in a string
.Length
Command to find the position of a specific character or substring in a string
.IndexOf()
Command to grab part of a string and return a new string
.Substring()
Command to change the case of strings to uppercase
.ToUpper()
Command to change the case of a string to lowercase
.ToLower()
Equals operator
==
Inequality operator
!=
Less than operator
Greater than operator
>
Less than or equal to operator
<=
Greater than or equal to operator
> =
AND operator
&&
OR operator
||
NOT operator
!
Clause to write a conditional
if
Clause to be executed if the if condition is false
else
Conditional statement to use to check for multiple conditions
else if
Statement which allows for compact control structures by evaluating a single expression and executing code blocks based on a matched case
switch
Specifies different potential values
case
Case to run if none of the conditions are met
default
Ternary operator
?
Ternary operator example
string color = “blue”
string result = (color == “blue”) ? “blue” : “NOT blue”;
PascalCase definition
First letter of each word in a compound word is capitalized
PascalCase example
YourMethodName
Operator for defining an optional parameter
=
Defining an optional parameter example
static void YourMethodName(string punctuation = “.”)
Named arguments command
YourMethodName(argumentName: argumentValue);
Named arguments example
YourMethodName(d: 4);
Int16 storage capacity
-32,768 to +32,767
Int32 storage capacity
-2,147,483,648 to +2,147,483,647
Int64 storage capacity
-9,223,372,036,854,775,808 to +9,223,372,036,854,775,807
Method overload definition
Having multiple versions of the same method but with different parameters
Method overload example
Math.Round(Double, Int32) vs Math.Round(Double)
Return type to be used if a method returns nothing
void
Return type to be used if a method returns nothing example
static void DecoratePlanet()
Return type to be used if a method returns a string example
static string DecoratePlanet()