zoukankan      html  css  js  c++  java
  • 接口的使用

       好长时间没用了.今年看 petshop 都有点快忘了.....


       Account.cs
    using System;
    using System.Reflection;
    using System.Configuration;

    namespace Z_Petshop
    {
        
    /// <summary>
        
    /// Account 的摘要说明。
        
    /// </summary>

        public class Account
        
    {
            

                
    public int SignIn(string userId, string password) 
                
    {

                
                    
    if ((userId.Trim() == string.Empty) || (password.Trim() == string.Empty))
                        
    return 10;

                
                         
                        
                     IAccount dal
    =(IAccount)Assembly.Load("Z_Petshop").CreateInstance ("Z_Petshop."+"Class_Account");
                    
                    
                    
    int account = dal.SignIn(userId, password);

                
                    
    return account;
                }


             }


        
    }



    Class_Account.cs

    using System;

    namespace Z_Petshop
    {
        
    /// <summary>
        
    /// Class_Account 的摘要说明。
        
    /// </summary>

        public class Class_Account : IAccount
        
    {
            
    public int SignIn(string userId, string password) 
            
    {
               
                
    return 100 ;

            }




        }

    }


    IAccount.cs

    using System;

    namespace Z_Petshop
    {
        
    /// <summary>
        
    /// Iaccount 的摘要说明。
        
    /// </summary>

        public interface IAccount
        
    {
            
            
    int SignIn(string userId, string password);

            
        }

    }

    调用页面

     
    private void Page_Load(object sender, System.EventArgs e)
            
    {
                
    // 在此处放置用户代码以初始化页面
                  Account s=new Account ();
                
                
                
    int I=s.SignIn ("100","100");
                
    this.Response .Write (I);

            }
  • 相关阅读:
    我来解数独(附delphi源码)
    jquery(三)
    jquery(二)
    jquery(一)
    前端之JS(五)
    前端之JS(四)
    前端之JS(三)
    前端之JS(二)
    前端之CSS(三)
    前端之CSS(二)
  • 原文地址:https://www.cnblogs.com/gwazy/p/154135.html
Copyright © 2011-2022 走看看