These are some exercises to better understand programming concepts in C#
-
Animal - Inheritance and polymorphism through method overriding.
-
New vs Override - Shows what happens when you forget not include the override keyword. In order to do this intentionally and avoid the warning use the new keyword
mono ForgotOverride.exe
Output
Base Sub Base
The Name property is not merely hidden it is overridden
mono WithOverride.exe
Output
Base Sub Sub
Using the
new
keyword gives the same result as not including theoverride
but gets rid of the warning . It is rarely used. OutputBase Sub Base
- Change directory to the specific folder
- Run the .exe file using mono C# compiler
For example
cd Animal/
mono Animal.exe
- Change directory to the Collections folder
- Change directory to the specific folder
- Run the .cs file using csharp command
For example
cd Collections/JaggedArrays/
csharp Cell.cs