zoukankan      html  css  js  c++  java
  • 接口、基类、子类

    1、定义一个接口

        interface BaseInterfa
        {
            void GetLogion();
            void RetureLogion();
        }

    2、定义一个子类,继承该接口

     internal class Logion:BaseInterfa
        {
            public string Name
            {
                get;
                set;
            }
    
            public string ID
            {
                get;
                set;
            }
    
            public int Age
            {
                get;
                set;
            }
    
            public void StaticArea()
            {
                MessageBox.Show("自己的函数");
            }
    
            public void GetLogion()
            {
                MessageBox.Show("基类的函数");
            }
    
            public void RetureLogion()
            {
                if (!string.IsNullOrEmpty(Name))
                {
                    MessageBox.Show("基类的函数" + Name);
                }
                else
                {
                    MessageBox.Show("Name属性为空。");
                }
            }
        }
    3、定义一个子类继承上面的父类

    class LogionName:Logion
        {
            public string LogionNames
            {
                get;
                set;
            }
    
            public string LogionID
            {
                get;
                set;
            }
    
            public void GetName()
            {
                MessageBox.Show(LogionNames + LogionID);
            }
        }



    主要是利用访问修饰符进行设计,保护安全


  • 相关阅读:
    记录我发现的第一个关于 Google 的 Bug
    iOS 中的 Delayed Transition
    Appstore|IPA
    地图|定位
    开发者账号
    App跳转
    国际化
    短信|彩信
    闪光灯
    Cornerstone|SVN
  • 原文地址:https://www.cnblogs.com/dengshiwei/p/4258707.html
Copyright © 2011-2022 走看看