访问类库里边的类时,只能访问到属性,不能访问到方法,在线等!
我写的一个class Base :
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Security.Cryptography;
using System.Text;
using Mis.DbBase;
namespace Mis.DbBase
{
public class User:Mis.DbBase.Base
{
private string m_Password;
private string emp_id;
public string Password
{
get{return m_Password;}
set{m_Password=value;}
}
public string Emp_Id
{
get{return emp_id;}
set{emp_id=value;}
}
public static void Add(string name,string password,string Emp_Id)
{
if(IsExist(Emp_Id))
{throw new Exception("This Name was registered");}
else
{
strSQL ="Insert into t_emp_info(emp_name,Password,emp_id) values("
+""+name+","
+""+password+","
+""+Emp_Id+")";
try
{ExecuteSql(strSQL);}
catch
{ throw new Exception("register failed");}
}
}
public static void Delete(int id)
{
strSQL="update t_emp_info set flag='0'where emp_id ="+id;
try
{ExecuteSql(strSQL);}
catch
{ throw new Exception("Register Failed");}
}
public static bool IsExist(string Emp_Id)
{
strSQL="select emp_id from t_emp_info where flag=1 and emp_id ='+id'";
try
{
ExecuteSql4Value(strSQL);
return true;}
catch
{
return false;
}
}
}
}
在引用这个类库时:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Mis.DbBase;
using DbBase;
namespace TheRest
{
/// <summary>
/// empFrm 的摘要说明。
/// </summary>
public class empFrm : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
Mis.DbBase.User user=new Mis.DbBase.User();
user.ID=TextBox1.Text;
user.Name=TextBox2.Text;
}
}
}
当我试图访问user对象时,只能访问到user下边的属性ID和Name,却不能访问user的方法Add(string name,string password,string Emp_Id);也就是当我输入user.的时候,后边只提示我的属性ID和Name,却没有方法Add(string name,string password,string Emp_Id)的提示;
请问高手,我怎么解决这样的问题?
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Security.Cryptography;
using System.Text;
using Mis.DbBase;
namespace Mis.DbBase
{
public class User:Mis.DbBase.Base
{
private string m_Password;
private string emp_id;
public string Password
{
get{return m_Password;}
set{m_Password=value;}
}
public string Emp_Id
{
get{return emp_id;}
set{emp_id=value;}
}
public static void Add(string name,string password,string Emp_Id)
{
if(IsExist(Emp_Id))
{throw new Exception("This Name was registered");}
else
{
strSQL ="Insert into t_emp_info(emp_name,Password,emp_id) values("
+""+name+","
+""+password+","
+""+Emp_Id+")";
try
{ExecuteSql(strSQL);}
catch
{ throw new Exception("register failed");}
}
}
public static void Delete(int id)
{
strSQL="update t_emp_info set flag='0'where emp_id ="+id;
try
{ExecuteSql(strSQL);}
catch
{ throw new Exception("Register Failed");}
}
public static bool IsExist(string Emp_Id)
{
strSQL="select emp_id from t_emp_info where flag=1 and emp_id ='+id'";
try
{
ExecuteSql4Value(strSQL);
return true;}
catch
{
return false;
}
}
}
}
在引用这个类库时:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Mis.DbBase;
using DbBase;
namespace TheRest
{
/// <summary>
/// empFrm 的摘要说明。
/// </summary>
public class empFrm : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
Mis.DbBase.User user=new Mis.DbBase.User();
user.ID=TextBox1.Text;
user.Name=TextBox2.Text;
}
}
}
当我试图访问user对象时,只能访问到user下边的属性ID和Name,却不能访问user的方法Add(string name,string password,string Emp_Id);也就是当我输入user.的时候,后边只提示我的属性ID和Name,却没有方法Add(string name,string password,string Emp_Id)的提示;
请问高手,我怎么解决这样的问题?
...全文
相关推荐
PHP中类属性与类静态变量的访问方法示例
主要介绍了PHP中类属性与类静态变量的访问方法,结合实例形式对比分析了php中类的属性、静态变量及常量的各种访问技巧,需要的朋友可以参考下
python中类的属性和方法介绍
Python-类属性,实例属性,类方法,静态方法,实例方法 类属性和实例属性 #coding:utf-8 class Student(object): name = 'I am a class variable' #类变量 >>> s = Student() # 创建实例s >>> print(s.name) # 打印name属性,因为实例并没有name属性,所以会继续查找class的name属性 Student >>> print(Student.name) # 打印类的name属性 Student >>> s.name = 'Michael' # 给实例绑定name属性 >>> pr
vue 本地服务不能被外部IP访问的完美解决方法
主要介绍了vue 本地服务不能被外部IP访问的解决方法,本文通过代码讲解的非常详细,需要的朋友可以参考下
C#中类、属性、字段、方法举例
C#中类、属性、字段、方法简单小例子 C#简单入门
C#类库C#类库C#类库C#类库C#类库
C#类库C#类库C#类库C#类库C#类库C#类库C#类库C#类库C#类库C#类库C#类库C#类库C#类库C#类库


