The teacher first introduced the difference between the structs and the class.
1. Structs is value types.
2. Structs can be instantiated without using a new operator. Structs can declare constructors, but they must take parameters, can not declare default Constructor-compiler would provide One & no destructor.
3. A struct cannot inherit from another struct or class, and it cannot be the base of a class. It is inherit from the base class Object. A struct can implement interfaces.
4. Within a struct declaration, fields cannot is initialized unless they are declared as const or static.
The format for defining strcts is as follows
And then I tried it myself. Defining a struct
Then the teacher explained to us the interface:
1. An interface was a contract that guarantees to a client how a class or struct would behave.
2. When a-class implements an interface, it tells any potential client "I guarantee I'll support all the methods, Properti ES, events, and indexers of the named interface. "
3. These contracts is made manifest (indicated) using the interface keyword, which declares a reference type that encapsulates th E contract.
The format for defining interface is as follows
I've also tried to define a interface.
Then the teacher identified the abstract Class, Interface and Mix-ins
1. An interface offers a alternative to a abstract class for creating contracts among classes and their clients.
2. The difference is so abstract classes serve as the top of a inheritance hierarchy, where as interfaces may add their contract to numerous inheritance trees.
Then I created a class to inherit this interface.
It would be nice to have multiple interfaces listed directly in the back, but it's worth noting that each interface is defined at the time of inheritance.
And we can also inherit in the interface and interface, this is relatively broad, can be one to the other can be many.
C # fourth time job