C# 101 Flashcards
What can I build with C#
A website, a console app, mobile, or AI
How do you output a line of text in a Console App (with no variables)?
Console.WriteLine(“Hello World!”);
What’s a Console App?
An command-line application that runs in the terminal window
How do you declare a string Variable?
string aFriend = “Kendra”
How would you output “Hello ____” using a string variable for the text to go in the blank?
string aFriend = “Scott”;
Console.WriteLine($”Hello {aFriend}”);
At the end of each line you need a…
semicolon ;
What is String Interpolation? Give an example.
Placing a variable between { and } characters to tell C# to replace that text with the value of the variable. Example:
string aFriend = “Scott”;
Console.WriteLine($”Hello {Scott}”);
What is a String?
A group of characters strung together
What character is really important when dealing with strings that contain variables?
The dollar sign ($), because it signals that the string to be output contains at least one variable.
What will the output look like?
string greeting = “ Hello World! “;
Console.WriteLine($”{greeting}”);
string trimmedGreeting = greeting.TrimStart();
Console.WriteLine($”[{trimmedGreeting}]”);
trimmedGreeting = greeting.TrimEnd();
Console.WriteLine($”[{trimmedGreeting}]”);
trimmedGreeting = greeting.Trim();
Console.WriteLine($”[{trimmedGreeting}]”);
** Hello World! **
[Hello World! ]
[ Hello World!]
[Hello World!]
What is an example of a String Method?
.TrimStart()
.Trim()
What is an example of a Property?
.Length
How do you run code in Visual Studio (hotkey)?
CTRL-F5
How would you declare the following variables?
int
double
decimal
int a = 3;
double b = 3.0;
decimal c = 3.0M;
What does the M in a decimal variable declaration represent?
The letter M was chosen as a visually-distinctive way to distinguish a decimal type from a double type.
I like to think of it as “deciMal”.