C # and VB.net

Source: Internet
Author: User

Interfaces in C #
Interface
[Public | protected | private] interface InterfaceName
{
// Mothed
// Propery
// Event
// Delegate
}
Differences between interfaces with and without Interfaces
Without the difference eg:
Public interface IMyShow
{
Void Show ();
}
Public class MyShow: IMyShow
{
Public void Show () // you must write the previous public statement. If the file is written as void Show (), an error occurs.
{
System. Console. Write ("without Interface Name ");
}
}
Public class MyMain
{
Public static void Main ()
{
// Reference with Class Definition
MyShow obj = new MyShow ();
Obj. Show ();
// Use the interface to reference the Method
IMyShow obj2 = new MyShow ();
Obj2.Show ();

}
}

// With the Interface Name
Public interface IMyShow
{
System. Console. Write ("with Interface Name ");
}
Public class MyShow: IMyShow
{
Void IMyShow. Show () // no prefix is allowed
{
System. Console. Write ("with Interface Name ");
}
}
Public class MyMain
{
Public static void Main ()
{
MyShow obj = new MyShow ();
Obj. Show (); // invalid because a qualified word is added, this method is a reference of the experts and can only be referenced by interfaces.
IMyShow obj2 = new MyShow ();
Obj2.Show ();
}
}
After reading the above content, I want to leave a question for C # hobbies. Let's discuss it together.
Public interface IMyShow
{
Void Show ();
}
Public interface IMyShow2
{
Void Show ();
}

Public class Myclass: IMyShow, IMyShow2
{
Public Myclass ()
{

}

Void IMyShow. Show ()

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.