Term
|
Definition
Describes the format and size of (amount of memory occupied by) a data item and defines what types of operations can be performed with the item.
Simple Types: int, double, decimal, char, string, bool
Other Types: String, Object |
|
|
Term
|
Definition
The statement that names a variable and reserves storage for it. You can have multiple variables on one line
Ex.) int myAge = 24, yourAge = 35; |
|
|
Term
|
Definition
The process of joining strings together
Ex.) WriteLine("The money is $" + someMoney); |
|
|
Term
|
Definition
Holds a position for a variable value within a string. It consists of a pair of curly braces containing a number that indicates the desired variable’s position in a list that follows the string. The first position is always position 0.
Ex.) WriteLine("The money is ${0} exactly", someMoney);
The above statement replaces "0" with whatever value is held in the variable someMoney. |
|
|
Term
|
Definition
A way to insert variables or expressions directly into a string using {}. It starts with a $ before the quotes, making string building easier and more readable.
Ex.) int someMoney = 45;
string mySentence = $"The money is ${someMoney} exactly.";
WriteLine(mySentence);
Output: The money is $45 exactly. |
|
|
Term
|
Definition
Stores whole numbers or characters, includes: int, short, long, byte, char, etc.
|
|
|
Term
Floating-Point Data Types |
|
Definition
Contains numbers that can have decimal places
Ex.)
float - Holds up to 7 significant digits of accuracy
double - holds 15-16 digits of accuracy
decimal - holds 28-29 digits of accuracy but smaller range (used in financial applications) |
|
|
Term
|
Definition
Addition, subtraction, multiplication, division, and remainder. Executes similarly to PEMDAS except you have the remainder operator as well.
Instead of:
counter = counter +1
You can shortcut with:
counter+=1;
Alternatives: -=, *=, /=, and %= |
|
|
Term
Prefix Increment (++x) and Decrement (--x) |
|
Definition
int x = 5;
int y = ++x;
//In this case, x is incremented to 6 before its value is assigned to y.
Console.WriteLine(x); // Output: 6
Console.WriteLine(y); // Output: 6 |
|
|
Term
Postfix Increment (x++) and Decrement (x--) |
|
Definition
int x = 5;
int y = x++;
// Here, x++ means y gets the value 5 (the original value of x), and then x is incremented to 6.
Console.WriteLine(x); // Output: 6
Console.WriteLine(y); // Output: 5
|
|
|
Term
|
Definition
Can hold only one of two values—true or false. Declared with data type bool.
|
|
|
Term
|
Definition
Compares two items, an expression containing one of these returns a Boolean value.
Ex.)
Less Than: <
Greater Than: >
Equal To: ==
Less Than Or Equal To: <=
Greater Than Or Equal To: >=
Not Equal To: != |
|
|
Term
|
Definition
A method in C# that is used to read input from the console as a string. It waits for the user to type something and press the Enter key, and then it returns whatever was typed as a string.
Ex.)
string name = Console.ReadLine();
// Reads user input and stores it in 'name' as a string
Console.WriteLine($"Hello, {name}!");
|
|
|
Term
|
Definition
Convert a string to a number in a different format.
[image] |
|
|
Term
|
Definition
An Alternative to using the convert class method to convert a string to a number. Turn a string into its numeric equivalent.
Ex.)
itemPrice = double.Parse(itemPriceAsString);
score = Int32.Parse(ReadLine( )); |
|
|
Term
|
Definition
Used to represent a single character. Can hold any single letter, number, symbol, or whitespace character. Enclosed in single quotes unlike strings.
Ex.)
____ letter = 'A'; |
|
|
Term
|
Definition
Always begins with a backslash, they are ways to store characters, even nonprinting characters like "tab" in a char variable. Ex.)
\t - tab
\n - newline
\"anyword"\ - adds quotations around a word
|
|
|
Term
|
Definition
Holds a series of characters, values are expressed within double quotation marks.
_____ firstName = "Bob"; |
|
|
Term
String Comparison Methods |
|
Definition
Equals( ): takes the format name1.Equals(name2); its value is true or false.
CompareTo( ): takes the format name1.CompareTo(name2); and its value is integer—0 when the compared strings are equal, a negative number if the first string is less, and a positive number if the second string (the one in parentheses) is less. |
|
|
Term
Methods for Manipulating Strings |
|
Definition
Length: a property not a method, therefore does not need parentheses. It gives you the length of a string. e.g. name.length
StartsWith( ): determines whether a string starts with certain characters and returns true or false. e.g. name.StartsWith("Wi")
Substring( ): Extracts a portion of a string from a starting point for a specific length
[image]
|
|
|