📄 interfaceexpl.cs
字号:
using System;
namespace Example_12
{
///<summary>
/// 此程序演示显式接口的实现。
///</summary>
//第一个接口
public interface IPict
{
int DeleteImage();
void DisplayImage();
}
//第二个接口
public interface IPictManip
{
void ApplyAlpha();
void DisplayImage();
}
public class BaseIO
{
public void Open()
{
Console.WriteLine("BaseIO 的 Open 方法");
}
}
//一个类和两个接口的实现
public class MyImages : BaseIO, IPict, IPictManip
{
public int DeleteImage()
{
Console.WriteLine("DeleteImage 实现!");
return(5);
}
public void ApplyAlpha()
{
Console.WriteLine("ApplyAlpha 实现!");
}
void IPict.DisplayImage()
{
Console.WriteLine("DisplayImage 的 IPict 实现");
}
void IPictManip.DisplayImage()
{
Console.WriteLine("DisplayImage 的 IPictManip 实现");
}
}
class Test
{
///<summary>
/// 应用程序的主入口点。
///</summary>
[STAThread]
static void Main(string[] args)
{
MyImages objM = new MyImages();
IPict Pict = objM; //IPict 引用
Pict.DisplayImage();
IPictManip PictManip = objM;
//IPictManip 引用
PictManip.DisplayImage();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -