CSF1 Flashcards
How do you create a single line comment?
//
Where does a program START to RUN?
** the Main() method**
Why can’t you break a string into 2 lines?
C# ignores whitespace except inside a string
What should you do with code that does not work?
do NOT delete code that does NOT work; comment out code that does NOT work
What is a variable?
a container;
contents can be changed;
must use some date type
Since a data type cannot be changed programatically…that means what?
It’s TYPE SAFE
Define…
Declaration vs. Initialization vs. Assignment
- Declaring means creating it: datatype & name
- Initializing means giving it a value for the first time
- Assigning means giving it a value
What’s missing here?
int thereCanBe
What’s the difference between the two lines of code?
thereCanBe = 1;
thereCanBe = 2
thereCanBe = 1; is the initiailization of the variable
thereCanBe = 2; is reassignment of the variable
string jedi = “Luke Skywalker”;
** Console.WriteLine(jedi);**
int bigNbr;
bigNbr = 55321;
//declare
//initialization //don't use commas!! they are for hoomans.
What’s the difference here?
Console.WriteLine(bigNbr);
Console.WriteLine(55321);
Console.WriteLine(“55321”)
ConsoleWriteLine() is an output to the screen
Line 1: is output the content of the varialbe
Line 2: is outputing a literal number
Line 3: is output as a string…the letters that look like numbers
What’s the difference between a string and an int?
int deadGoblins = 57460;
int deadOrcs = 42540;
Console.WriteLine(“Orcs Killed: “ + deadOrcs);
Console.WriteLine(“Total Monsters Killed: “
\+ (deadGoblins + deadOrcs));
**What is contatenation? **
adding strings and objects together (b/c everything is an object)
the () around the numeric calcuation trumps the order
of operations and makes sure the concatenation happens AFTER the calculation
What are the rules to naming a variable?
- can only begin with alpha characters
*or underscores _
-After the first character you can use alpha, numberic, or underscore
- CANNOT contain spaces.
- MUST contain at least 1 alpha or numeric
- CANNOT be a C# reserved keyword (pg.19)
-MUST be unique within its scope {}
* */
What’s the difference?
if deadOrcs has already been declared and initialized
int deadOrcs = 43540;
** deadOrcs = 43540;**
**What are constants? **
they are variables that MUST be assigned when declared; the value cannot be reassigned
What does a constant variable look like?
constant datatype variableName = value
Do multiple variables, of the same datatype, have to be declared and initialized individually?
No, they can all be declared together…and initialized individually
What makes up a variable?
datatype variableName = value
it can be declared and initialized at the same time or declared then initialized later
How would declare multiple varialbes, but only initialize one variable?
int blasters, spears, lightsabers = 10;
only lightsabers was initialized
What’s happening here?
** int coaches = 2, players = 30, cheerleaders = 15;**
variables of the same type are being declared and initialized all at the same time