- const keyword (as opposed to 'final'?)
- C# is 'pass by value' unless otherwise specified:
- use the ref keyword with parameters AND arguments to 'pass by reference'
- use the out keyword with parameters AND arguments to 'pass by reference' without being able to access the old pre-method value
- Overloading the constructor:
- public Constructor (params) : this (params) {}
- Pay extra note: the constructor calls are BEFORE the block
- Implementing an interface:
- public class MyClass : IMyInterface {}
- pay note to the 'I' in front of MyInterface. Good convention.
- Inheriting a class:
- public class MyChildClass : MyParentclass {}
- the fact that there is no difference in syntax between inheriting a class and implementing an interface is an EXTRA (good) reason to obey the 'I in front' naming convention for interfaces.
- Overriding a Parentclass method:
- Parentclass method must have the keyword 'virtual'
- Childclass overriding method must have the keyword 'override'
- This make the default 'behavior' of ParentClasses that they CAN'T be overridden. Probably more secure :)
- Again: the keyword 'virtual' and 'override' form a pair which is needed to override methods.
- Calling the Parentclass method from within the Childclass:
- base.parentMethod(args)
woensdag 30 december 2015
First steps in C# (from a Java perspective)
Abonneren op:
Reacties posten (Atom)
Geen opmerkingen:
Een reactie posten