首页 > 代码库 > C# to IL Reference and Value Types(引用类型和值类型)

C# to IL Reference and Value Types(引用类型和值类型)

技术分享

An interface is a reference type, in spite of the fact that it has no code at all. Thus, we
cannot instantiate an interface. We can use it as a construct for the creation of new types.
An interface defines a contract that is left to the class to implement.
An interface can have static fields. If an interface contains 10 abstract virtual functions,
then the class implementing from that interface has to supply the code for all 10 of them.
Thus, if a class does not provide all the function implementations, then we cannot use the
class. In such a scenario, a class derived from it must provide the implementation.
The interface keyword in C# is a class, which the documentation describes as a semantic
attribute.

技术分享

We are not allowed to place any code in an interface. An interface consists only of the
function prototype, followed by a pair of curly braces {}

技术分享

技术分享

vijay1 is a function created in the interface yyy. As this is not permitted, the il assembler
has the domino effect as shown above


C# to IL Reference and Value Types(引用类型和值类型)