zoukankan      html  css  js  c++  java
  • 接口interface实现与显示实现

    接口实现:

    interface IMath
    {
    void Add(int x, int y);
    }

    public class MathClass : IMath
    {
    public void Add(int x, int y)
    {
    Console.WriteLine("This is the interface implementation :{0}+{1}={2}", x, y, x + y);
    }
    }

    class Program
    {
    static void Main(string[] args)
    {
    int x = 897, y = 987;
    MathClass obj = new MathClass();
    obj.Add(x, y);
    IMath IObj = new MathClass();
    IObj.Add(x, y);
    Console.ReadLine();
    }

    接口显示实现:

    interface IMath
    {
    void Add(int x, int y);
    }

    public class MathClass : IMath
    {
    void IMath.Add(int x, int y)
    {
    Console.WriteLine("This is the explicitly implement the IMath :{0}+{1}={2}", x, y, x + y);
    }
    }

    class Program
    {
    static void Main(string[] args)
    {
    int x = 987654, y = 90890;
    IMath Obj = new MathClass();
    Obj.Add(x, y);
    Console.ReadLine();
    }
    }

  • 相关阅读:
    3.29上午
    3.28下午
    3.28上午
    3.27下午
    3.24的下午
    2017.3.16上午学习内容
    2017.3.15上午学习内容
    2017.3.14下午学习内容
    2017.3.14上午学习内容
    2017.3.13下午学习内容
  • 原文地址:https://www.cnblogs.com/Fred1987/p/5980680.html
Copyright © 2011-2022 走看看