110,566
社区成员
发帖
与我相关
我的任务
分享
public partial class Component1 : Component
{
public Component1()
{
InitializeComponent();
}
public Component1(IContainer container)
{
container.Add(this);
InitializeComponent();
}
}
public class sqlhelper
{
public string connetionStr;
public sqlhelper()
{
}
public connect()
{
//连接数据库
}
}
你就必须这样用:
sqlhelper s=new sqlhelper();
s.connetionStr=str;
s.connect();
而如果用带参数的构造函数,就可以这样
public class sqlhelper
{
public sqlhelper()
{
}
public sqlhelper(connetionStr)
{
//建立连接
}
}
sqlhelper s=new sqlhelper(str);