Command line in Windows is more common than it was
Drives > Folders/Directories > Files
Ways to navigate:
-
Absolute = Start from the top
-
Relative = start from current folder
-
home directory:
~
-
this folder:
.
-
explorer
: same asopen
on mac -
pwd
: print working directory
- Source control: system used to track all the ongoing changes that are made to a codebase
- Git or TFS: (microsoft based version control)
- Repository: houses all of the code and changes
- Clone: downloads a copy of a remote repository to your computer
- Origin: name given to the remote repository
- Stage: identify which files will be committed
- Push: copies changes from local to remote repository
- Pull: fetches updates from a remote repository
- Fork: create a copy of a remote repository
- Upstream: the original (I don't have control over this)
- My copy is called origin
- C#: object oriented programming language
- Similar to C, C++, Java, Javascript…
- Compiled into machine level instructions
- It runs on .Net… Using C# implies that you’re using .Net
- .Net: a framework
- Provides a way of building applications and includes over 6,000 classes
- Helps us complete our tasks (e.g. databases, email, security, etc.)
- I know the task - but I don’t know what class or function to use - so I look it up
- .Net core & .Net Standard
- Core works on many platforms - linux, mac. Only new programs - 3 years old.
- Standard works only on windows and has many more classes
- CLR: common language runtime - something that can process the application
- IDE: Integrated Development Environment - we use Visual Studio
- Includes ability to troubleshoot, organize, write and run code
- Visual Studio Community 2017
- Solution: .sln
- C# Projects: .csproj
- C# Files: .cs
- C# Classes
- Methods
- C# Classes
- C# Files: .cs
- C# Projects: .csproj
- A second project could be a test project - testing the other code we wrote
- Keyboard Shortcuts
- Run Program: CTRL + F5
- Debug Program: F5
- Step through code execution
- Solution: .sln
- Intilesense: Autocomplete
- Methods: Functions
- Statement: a unit of code that is executed - carries out an action. Ends in a semicolon ;
- Block: one or more statements of code. Enclosed in curly braces
{ int x = 3; }
- Scope: code within a block is inside a scope, you can't re-declare variable
{
int x = 3;
int x = 4; // error, already declared within this scope
}
{
int x = 4; // this is fine, they're in different blocks
}
- Expression - a statement of code that evaluates to a single result
- Arithmetic expression:
int x = y + 3;
decimal x = 3M;
x += 3; // result: 6M
- Arithmetic operators:
+
add-
subtract*
multiply/
divide%
remainder or mod
32/2 // result: 16
32 % 2 // result: 0
32 % 3 // result: 2
- For the integer operands, the result of
a % b
is the value produced bya - (a / b) * b
- The sign of the non-zero remainder is the same as that of the first operand, as the following example shows:
Console.WriteLine(5 % 4); // output: 1
Console.WriteLine(5 % -4); // output: 1
Console.WriteLine(-5 % 4); // output: -1
Console.WriteLine(-5 % -4); // output: -1
- Boolean expression
true
orfalse
x == y;
3 == 4;
→ false;
- Comparison operators:
==
equality>
greater than (not inclusive)<
less than (not inclusive)>=
greater than or equal to<=
less than or equal to!=
not equal
- Double: numbers with a decimal point
- Decimal: very precise decimal numbers that you’d use for keeping track of money
- Method: a named block of code. It can accept input values and provides an output value
// `access modifier` `return type` `name` (`parameters/arguments`)
public int AddTwo (int x, int y)
{
int sum = x+y;
return sum;
}
Logical Operators:
&&
AND||
OR!
NOT^
XOR (eXclusive OR): a or b but not both
- Arrays: A series of objects of which all items (referred to as elements) are the same type (integers, booleans, etc.)
- Elements are accessed by Index (your current location)
- Length: The size of an array. It is fixed and determined when the array is initialized.
// Declare & assign an array:
// `name` = `type`[`# of elements in array in the correct type`];
scores = new int[4];
Tells computer to assign space for 4 ints in memory.