Namespace
Namespaces provide a hierarchical means of organizing C# programs and libraries.
Namespaces contain types and other namespaces—for example, the System namespace contains many types, such as the Console class referenced in the program, and many other namespaces, such as IO and Collections
using
A using directive that references a given namespace enables unqualified use of the types that are members of that namespace.
Because of the using directive, the program can use Console.WriteLine as shorthand for System.Console.WriteLine
Access Modifiers
2 types of protected acess modifiers
proteced: private and internal
W C# oraz .NET, assembly to podstawowy blok wykonywalny aplikacji, który może być plikiem wykonywalnym (.exe) lub biblioteką (.dll).
Assembly to jednostka wdrożenia, która zawiera kod, zasoby, a także informacje o metadanych niezbędne do wykonania tego kodu.
Termin current assembly odnosi się do tego konkretnego assembly, w którym aktualnie znajduje się kod, czyli kod wykonujący się w danym momencie. Jest to po prostu assembly, w którym znajduje się definicja klasy lub członka, którego dotyczy kontrola dostępu.
2 types of values
based on how they occupy the memory
1. value type
2. reference type
value type
stored directly
typically stored in stack
reference type
stores the memory location of data, variable
stores memory reference, not value directly
value type
reference type
acdis
Primitive data types
2 types of conversion
implicit- no risk of losing data
explicit- with risk of losing data, double to int
var
-from c# 3.0, to declare local variables
-compiler determines the data type
-cannot be null
Encapsulation
Encapsulation- practice of hiding the internal state of an object and allowing access and modification through methods
-Data integrity
-Reduce complexity
-Abstraction- hide the implementation details
Private field logic
public property- getters and setters accessors, control access
auto-implemented properties
automaticlly creates a field ,
automaticlly creats a getter and a setter
Finalizer/Destructor
Inheritance
define a class within another class,
A class can inherint from a single class and multiple interfaces
virtual keyword
can be overridden in classes that inherits from this class
then we use override keyword
Polymorhpish
using new keyword in the method is not a overrridening but giving higher priority
sealed keyword-
the method or a class cannot be overridden
abstract class
class- cannot create an instance of abstract class, just the blueprint
method- a method that has to be implemented!
to compare if is an instance of a class-
as/ is keyword
Cube iceCube = element as Cube
if element is Cube
Abstract classes and interfaces
cant create an instance of it
both support polymorphism
Abstract classes and interfaces compare
Abstract classes:
can have constructor
can be partially implemented
can contain fields
only one inherit
-> AND Interfaces cant and class implement many