Untitled
Slides in this set (6)
-
- A handy guide to C# for those that are taking A Level Computer Science without any knowledge of the language.
-

- Caption: Month is the property that can be changed and have certain conditions of the value that is entered. The Month property can be set to read only (so only a get function is assigned) or write only (only a set function )
- Fields are variables inside a class that are private and can't be changed directly. This minimises errors in the code, improves its security.
- The field in the example to the right is _month.
- The Properties for the example to the right is Month.
-
- The method in this example is the getters and setters of the property, using the if statements for the set and just returning the field for the get method.
- Examples of methods include the get and set. The general term for methods are the stuff inside a property or function.

-
- The idea of wrapping a private field with a public property to allow the specifications of a value to be set.
- In the example to the right, there are specifications of the field
- _month due to the property. By using the property, (Month) we can encapsulate the field by defining the field with the properties data, but the user is not accessing the field at any time, and can only reference the property.

-
Derived and Base classes: Inheritance
- Derived class: The class that inherits the original class.
- Base class: The original class.
- To inherit we use colons (:)
- We inherit classes so we can make use of functions for other classes instead of typing them all out again. Code reusability too.
-
- Similar to inheritance whereby we reuse existing classes to use specific functions. For example, a base class called Animal has an animal sound and the classes Dog, Cat and Pig inherit this class but change it so that the function uses the animal's individual sound.
Information
- Description
- Slide Set on Untitled, created by Harriet Leplar on 13/04/2021.
- Created by
- Harriet Leplar
- Views
- 0
- Rating