"C # to IL" fourth chapter keywords and operators (bottom)

Source: Internet
Author: User
Tags mscorlib

We created an interface III, which has only one function named PQR. Then, the class YYY implements Interface III, but does not implement the function PQR, but instead adds a function called ABC. In the entry point function Vijay, the function PQR is called by Interface III.

We did not get any errors because of the existence of the override directive. This instruction notifies the compiler to redirect any calls to the function PQR of interface III and to the function ABC of the class yyy. The compiler is very strict with the override instructions. This can be considered from the fact that if III is not implemented in the definition of class yyy, then we get the following exception:

Output

Exception Occurred:System.TypeLoadException:Class yyy tried to override method PQR but does not implement or inherit tha T methods.

At Zzz.vijay ()

destructor

A.cs

class zzz
{
public static void Main()
{
}
~zzz()
{
System.Console.WriteLine("hi");
}
}

A.il

.assembly mukhi {}
.class private auto ansi zzz extends [mscorlib]System.Object
{
.method public hidebysig static void vijay() il managed
{
.entrypoint
ret
}
.method family hidebysig virtual instance void Finalize() il managed
{
ldstr      "hi"
call void [mscorlib]System.Console::WriteLine(class System.String)
ldarg.0
call        instance void [mscorlib]System.Object::Finalize()
ret
}
}

No output

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.