C# Flashcards
sealed
prevents a class from being inherited
private
The code is only accessible within the same class
public
The code is accessible for all classes
protected
The code is accessible within the same class, or in a class that is inherited from that class.
internal
The code is only accessible within its own assembly, but not from another assembly.
static
The method belongs to the Program class and not an object of the Program class.
void
The method does not have a return value.
properties
A property is like a combination of a variable and a method, and it has two methods: a get and a set method.
field
A variable declared directly in a class. Best practice to start name with lower case letter.
Properties and fields naming convention
Best practice to start name of a Property an with uppercase letter and the name of a field with a lower case letter.
Ex:
class Person {
private string name; // field
public string Name // property { get { return name; } // get method set { name = value; } // set method } }
Method Overloading
With method overloading, multiple methods can have the same name with different parameters.
Ex: int MyMethod(int x) float MyMethod(float x) double MyMethod(double x, double y)
virtual
Indicates that a class member can be overridden by an inherited class.
override
Indicates that a class member will override a virtual class member from the parent class.
class member
Fields or methods within a class.
Abstract class
A restricted class that cannot be used to create objects (to access it, it must be inherited from another class).