接口的使用

   好长时间没用了.今年看 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);

        }

posted on 2005-05-12 17:01  gwazy  阅读(486)  评论(0编辑  收藏  举报

导航