1. Intro
    1. C# vs .NET
      1. C#
        1. is a programming Lang
      2. .NET
        1. framework for building applications on Windows
          1. also support diff lang
          2. VB.NET
          3. F#
    2. .NET
      1. consists of
        1. CLR (Common Language Runtime)
          1. translate IL(Intermediate Language) into Native Code
          2. JIT (Just In Time Compilation)
        2. Class Library
          1. for building applications
          2. Classes collaborate with each other at runtime
    3. Architecture of .NET Applications
      1. Application
        1. consists of building blocks called Classes
      2. Class
        1. Attributes
          1. state of application
        2. Functions/Methods
          1. behavior
          2. execute code
      3. Namespace
        1. way to organize Classes
        2. container for related classes
      4. Assembly
        1. way of partitioning an application
        2. container for related namespaces/classes
        3. File on disk
          1. DLL
          2. Dynamically Link Library
          3. a file that includes code that can be re-used across different programs
          4. EXE
          5. a program that can be executed
      5. When application is complied
        1. compiler builds 1 or more assemblies(depending on how code is partition)
    4. Visual Studio
      1. Run
        1. Ctrl + F5
      2. Delete line
        1. Ctrl + X
      3. ReSharper
        1. Alt + Enter
        2. Get rid of unused "using" namespaces
      4. Console.WriteLine()
      5. Compile
        1. Ctrl + Shift + B
  2. 3. Primitive Types & Expressions
    1. 14. Variables & Constants
      1. Variable
        1. Name given to a storage location in memory
        2. Use Camel Case
          1. Eg.
          2. firstName
      2. Constant
        1. Immutable value
        2. const float Pi = 3.14f;
        3. Use Pascal Case
          1. Eg.
          2. MaxZoom
      3. Primitive Types
        1. byte
        2. int
        3. long
        4. decimal
        5. char
        6. bool
    2. 15. Overflowing
      1. "checked" keyword
      2. Use
        1. checked { byte number = 255; number = number +1; // 0 }
      3. will throw exception if run
      4. without "checked", it'll overflow without error returning "0"
    3. 16. Scope
    4. 17. Demo
      1. Default number with decimal
        1. double
        2. need to append 'f' behind the decimal number
          1. Eg.
          2. float total = 123.12f
      2. Keywords are in blue
      3. Code snippet
        1. Shortcut for "Console.WriteLine()"
          1. type "cw", double Tab
      4. "var" keyword
      5. Object Browser
        1. "Ctrl + click" on keywords
          1. doesn't work! -RL
      6. Place-holder
        1. Eg.
          1. Console.WriteLine("{0} {1}", byte.MinValue, byte.MaxValue);
          2. {0}
          3. 1st place-holder format
    5. 18. Type Conversion
      1. Implicit Type Conversion
        1. No data lose
        2. Eg.
          1. byte b = 1; int i = b;
          2. int i = 1; float f = i;
      2. Explicit Type Conversion(Casting)
        1. Data will be lost if the "type" is beyond the capacity
        2. Eg.
          1. w/o Casting
          2. CANNOT Compile
          3. int i = 1; byte b = i;
          4. w/ Casting
          5. CAN Compile
          6. int i = 1; byte b = (byte)i;
          7. float f = 1.0f; int i = (int)f;
      3. Conversion between Non-compatible types
        1. use
          1. Convert class
          2. Eg.
          3. string s = "3"; int i = Convert.ToInt32(s);
          4. ToByte()
          5. ToInt16()
          6. short
          7. ToInt32()
          8. int
          9. ToInt64()
          10. long
          11. Parse method
          12. Eg.
          13. string s = "3"; int j = int.Parse(s);
    6. 19. Demo - Type Conversion
      1. Exception handling
        1. try/catch
          1. try { } catch (Exception) { }
    7. 20. Operators
      1. Arithmetic
        1. Add
          1. +
        2. Subtract
          1. -
        3. Multiple
          1. *
        4. Divide
          1. /
        5. Remainder
          1. %
        6. Increment
          1. ++
        7. Decrement
          1. --
        8. Prefix
          1. Eg.
          2. int a = 1; int b = ++a; // a = 2, b = 2
        9. Postfix
          1. Eg.
          2. int a = 1; int b = a++; // a = 2, b = 1
      2. Comparison
        1. Equal
          1. ==
        2. Not Equal
          1. !=
        3. Greater than
          1. >
        4. Greater than or equal to
          1. >=
        5. Less than
          1. <
        6. Less than or equal to
          1. <=
      3. Assignment
        1. Assignment
          1. =
        2. Addition
          1. +=
        3. Subtraction
          1. -=
        4. Multiplication
          1. *=
        5. Division
          1. /=
      4. Logical
        1. And
          1. &&
        2. Or
          1. ||
        3. Not
          1. !
      5. Bitwise
        1. for low level Programming
        2. And
          1. &
        3. Or
          1. |
    8. 21. What are Logical Operators?
      1. &&
        1. ONLY if both are true, it's true
      2. ||
        1. If ANY of the both is true, it's true
    9. 23. Demo - Operators
      1. if division of 2 int, return will be int as well
        1. Eg.
          1. var a = 10; var b = 3; Console.WriteLine(a / b); // return 3
          2. var a = 10; var b = 3; Console.WriteLine((float)a / (float)b); // return 3.333333
      2. changing precedence
        1. use
          1. parenthesis
          2. ()
    10. 24.
      1. Comments
        1. Single-line
          1. // This is a comment.
        2. Multi-line
          1. /* This is a comment. This is a comment too. */
  3. 4. Non-primitive Types
    1. 26. Classes
      1. Variables(Fields)
      2. functions(Methods)
      3. Object
        1. instance of a Class
      4. Declaring
        1. Access modifier
          1. Eg.
          2. public
        2. "class" keyword
        3. identifier
          1. Eg.
          2. Person
      5. Eg.
        1. public class Person { public string Name; public void Introduce() { Console.WriteLine("Hi, my name is " + Name); } }
      6. Creating Objects
        1. Eg.
          1. var person = new Person(); person.Name = "Richard"; person.Introduce();
      7. Static Modifier
        1. can directly access the method through the Class itself, w/o creating an Object
        2. Eg.
          1. public class Calculator { public static int Add(int x, int y) { return x + y; } } int result = Calculator.Add(1, 2);
    2. 27. Demo - Classes
      1. Move class to a file
        1. select the class
          1. Press - Alt + Enter
          2. or
          3. Press Ctrl + "."
      2. Switch between different Windows
        1. Ctrl + tab
    3. 28. Structs
      1. similar to Classes
      2. Eg.
        1. public struct RgbColor { public int Red; public int Green; public int Blue; }
      3. not frequently used
      4. use if you want to define a small lightweight object, or else just stick to Classes
      5. more efficient to define as struct if need to define lots of it
    4. 29. Arrays
      1. What is?
        1. Data structure to store a collection of variables of the same type
      2. Declaring
        1. Eg.
          1. int[] numbers = new int[3];
          2. int[]
          3. declaring array
          4. int[3]
          5. set size of array
          6. var numbers = new int[3];
      3. Initializing
        1. Eg.
          1. int[] numbers = new int[3] {1, 2, 3};
      4. Access Array Elements
        1. Eg.
          1. numbers[1] = 3;
    5. 30. Demo - Arrays
    6. 31. Strings
      1. What is?
        1. sequence of characters
        2. Eg.
          1. "Hello World"
      2. How to create?
        1. Using
          1. Literals
          2. Eg.
          3. string firstName = "Richard";
          4. Concatenation
          5. Eg.
          6. string name = firstName + " " + lastName;
          7. Format
          8. Eg.
          9. string name = string.Format("{0} {1}", firstName, lastName);
          10. {0}
          11. Place holder
          12. Join
          13. Eg.
          14. var numbers = new int[3] {1, 2, 3}; string list = string.Join(",", numbers); // return 1,2,3
      3. String Elements
        1. Eg.
          1. string name = "Richard"; char firstChar = name[0]; // return 'R'
      4. Strings are Immutable
        1. Once Created, CANNOT change!
          1. name[0] = 'r';
      5. Escape Characters
        1. Use
          1. \n
          2. New Line
          3. \t
          4. Tab
          5. \\
          6. Backslash
          7. \'
          8. Single Quotation Mark
          9. \"
          10. Double Quotation Mark
        2. Eg.
          1. string path = "c:\\projects\\project1\\folders";
      6. Verbatim Strings
        1. Use
          1. @
        2. Eg.
          1. string path = @"c:\projects\project1\folders";
    7. 32. Demo - Strings
      1. .NET
        1. string
          1. map to
          2. String
          3. class
        2. int
          1. map to
          2. Int32
          3. struct
        3. Eg.
          1. String firstName = "Richard";
          2. Can also use "String" keyword instead of "string"
          3. Have to import "using System"
    8. 33. Enums
      1. What is?
        1. A set of name/value pairs (constants)
      2. When to use?
        1. you've a number of related constants
      3. Eg.
        1. public enum ShippingMethod { RegularAirMail = 1, RegisteredAirMail = 2, Express = 3; }
      4. Info
        1. Internally an Integer
        2. How to change to byte?
          1. public enum ShippingMethod : byte { RegularAirMail = 1, RegisteredAirMail = 2, Express = 3; }
      5. How to use?
        1. Eg.
          1. var method = ShippingMethod.Express;
      6. How to use?
        1. Convert to Int
          1. Cast
          2. Eg.
          3. Console.WriteLine((int)method);
          4. return
          5. 3
        2. Convert to String
          1. .ToString() method
          2. Eg.
          3. var methodStr = ShippingMethod.RegisterdAirMail.ToString(); Console.WriteLine(methodStr);
        3. Convert to Enum
          1. Parse
          2. Eg.
          3. var methodName = "RegisterdAirMail"; var shippingMethod = (ShippingMethod)Enum.Parse(typeof(ShippingMethod), methodName);
          4. return
          5. "RegisterAirMail"
    9. 34. Demo - Enums
    10. 35. Reference Types & Values Types
      1. Primitive Types
        1. Eg.
          1. int
          2. char
          3. float
          4. bool
      2. Non-primitive Types
        1. Eg.
          1. classes
          2. structures
          3. arrays
          4. map to
          5. System.Array
          6. strings
          7. map to
          8. System.String
      3. 2 main types
        1. for which we create new types
        2. What are they?
          1. Value Types
          2. Structures
          3. for
          4. Primitive types
          5. Custom structures
          6. Allocate on stack
          7. Memory allocation done automatically
          8. Immediately removed when out of scope
          9. by Runtime/CLR
          10. Reference Types
          11. Classes
          12. for
          13. Arrays
          14. Strings
          15. Custom classes
          16. Need to allocate memory
          17. using "new"
          18. Memory allocated on
          19. Heap
          20. more sustainable
          21. if object goes out of scope, it won't be removed immediately. It'll continue to be in heap for a little while.
          22. Garbage collected by Runtime/CLR
        3. Copying of reference types & value types are different