Presentation is loading. Please wait.

Presentation is loading. Please wait.

5. 3 Coding with Denotations

Similar presentations


Presentation on theme: "5. 3 Coding with Denotations"— Presentation transcript:

1 5. 3 Coding with Denotations
Microsoft .NET 5. 3 Coding with Denotations Pan Wuming 2017

2 Topics Coding with Denotations Enumeration Types Interfaces
References: C# Programming Guide(MSDN) Covariance and Contravariance in Generics(MSDN)

3 Coding with Denotations
Denoting Collection of Names Denoting Behavior Group Referring to Behaviors Enumerations Interfaces Delegates

4 Enumeration Types An enumeration type provides an efficient way to define a set of named integral constants By default the underlying type of each element in the enum is int. You can specify another integral numeric type for a enum type.

5

6 Enumeration Types as Bit Flags
Bit flags enables an instance of the enumeration type to store any combination of the values that are defined in the enumerator list. AND, OR, NOT and XOR bitwise operations can be performed on them

7

8

9 Interfaces An interface contains definitions for a group of related functionalities that a class or a struct can implement. Any class or struct that implements an interface must implement all its members. An interface can't be instantiated directly. Interfaces can contain events, indexers, methods, and properties. Interfaces contain no implementation of methods. A class or struct can implement multiple interfaces.

10

11 Explicit Interface Implementation

12 Variant Generic Interfaces
Covariance allows interface methods to have more derived return types than that defined by the generic type parameters. Contravariance allows interface methods to have argument types that are less derived than that specified by the generic parameters.


Download ppt "5. 3 Coding with Denotations"

Similar presentations


Ads by Google