OOP PROGRAMMING

Cards (33)

  • C# ignores white space
    However, multiple lines makes the code more readable
  • C# uses {} curly braces
    As markers of beginning and end of a chunk of code
  • "using [NameOfNamespace]"
    Is used to import namespaces and use classes of it
  • "namespace"
    Is used to organize codes; a container for classes and other namespaces
  • C# statement
    Ends with a semicolon ;
  • C# file name
    Does not have to match the class name, but they often do (for better organization)
  • C# is case-sensitive
    "MyClass" and "myclass" have different meaning
  • C# usually has the Main method

    Any code inside its curly brackets {} will be executed (Program entry point)
  • Comments
    Multi-line and single line
  • String
    Using double quotations ("") to print texts/strings
  • Statement
    A single line of code that ends in a semicolon, or a series of single-line statements in a block
  • Statement block
    Enclosed in {} brackets and can contain nested blocks
  • Declaration statement
    Introduces a new variable or constant. A variable declaration can optionally assign a value to the variable. In a constant declaration, the assignment is required.
  • Constant
    Immutable values which are known at compile time and do not change for the life of the program. Declared with the const modifier.
  • Expression statement
    Expression statements that calculate a value must store the value in a variable. Assignment, method invocation, new object creation.
  • Method
    A set of instructions grouped together within a code block. When a program needs to carry out these instructions, it calls the method and provides any necessary arguments.
  • Main method
    The starting point for any C# program, initiated by the common language runtime (CLR) upon program launch.
  • Method declaration
    • Access level (e.g. public, private)
    • Optional modifiers (e.g. abstract, sealed)
    • Return value
    • Name
    • Method parameters
  • Method signature
    The parts of a method declaration that together define the method
  • Calling a method
    • Motorcycle.MethodName()
  • Method parameters vs arguments
    Parameters are the names and types defined in the method declaration, arguments are the concrete values provided when calling the method
  • Passing by reference vs value
    Value types are passed by copy, reference types are passed by reference. Use the ref keyword to pass value types by reference.
  • Return values
    Methods can return values to the caller, either by value or by reference using the return statement. The return statement also stops method execution.
  • Custom methods
    User-defined methods that contain a specific set of code instructions, declared within a class or struct. Can be used to organize code, reuse code, and define custom business logic.
  • Method overloading
    Defining multiple methods with the same name but different parameter lists within the same class
  • Arrays
    • Single-dimensional
    • Multi-dimensional
    • Jagged
  • Single-dimensional array
    A sequence of like elements accessed by index
  • Multi-dimensional array
    Arrays with more than one dimension
  • Jagged array
    An array of arrays, possibly of different sizes
  • ArrayList
    • Stores elements of multiple data types whose size can be changed dynamically
  • Linked list
    • A linear data structure where each element (node) contains data and a reference to the next node
  • Access modifiers
    public: accessible for all classes
    private: only accessible within the same class
    protected: accessible within the same class or inherited classes
    internal: only accessible within the same assembly
  • private access modifier
    • A private field can only be accessed within the same class