主题:请教一个类库层次带来的问题
//库代码简如下
class Lib
{
public class DataBase
{
public Result result;
public DataBase(string ConnectionString)
{
//...
result = new Result();
}
public bool Open(string sql)
{
//...
return true;
}
public bool Close()
{
//...
return true;
}
//...
}
public class Result
{
int iCount = 0;
public int Count
{
get
{
return iCount;
}
}
public string Field(long RowIndex,long ColIndex)
{
//...
return "...";
}
public string Field(string RHValue, string CHValue)
{
//...
return "...";
}
//...
}
}
//应用程序代码
class frmObj
{
DataBase ndb;
public frmObj()
{
ndb = new DataBase("...");
}
private void Exec(string sql)
{
if (ndb.Open(sql))
{
for (long i = 0; i < ndb.result.Count; i++)
{
//...
}
}
}
}
也不知道打侠们能不能看懂
我没有系统的学习过C# 不知道这样写对不对 如果不对的话 请高手点评
问题是这样子的:
我把类库(DataBase与Result等)编译之后 ,在应用程序(frmObj)中应用,没有问题。
但我希望应用程在序引用类库之后,不能看到Result类,所以我将Result类设置成Private,结果会有可访问性不一致的错误,内部类好象也不行,然后我又试了一下abstract,sealed,override,virtual等几个修饰符也没能达到效果,也不知道是不是我使用的时候出的问题还是怎么回事。
希望各位大侠能够帮忙解答一下,怎么才能达到这样的效果。在此谢过了
class Lib
{
public class DataBase
{
public Result result;
public DataBase(string ConnectionString)
{
//...
result = new Result();
}
public bool Open(string sql)
{
//...
return true;
}
public bool Close()
{
//...
return true;
}
//...
}
public class Result
{
int iCount = 0;
public int Count
{
get
{
return iCount;
}
}
public string Field(long RowIndex,long ColIndex)
{
//...
return "...";
}
public string Field(string RHValue, string CHValue)
{
//...
return "...";
}
//...
}
}
//应用程序代码
class frmObj
{
DataBase ndb;
public frmObj()
{
ndb = new DataBase("...");
}
private void Exec(string sql)
{
if (ndb.Open(sql))
{
for (long i = 0; i < ndb.result.Count; i++)
{
//...
}
}
}
}
也不知道打侠们能不能看懂
我没有系统的学习过C# 不知道这样写对不对 如果不对的话 请高手点评
问题是这样子的:
我把类库(DataBase与Result等)编译之后 ,在应用程序(frmObj)中应用,没有问题。
但我希望应用程在序引用类库之后,不能看到Result类,所以我将Result类设置成Private,结果会有可访问性不一致的错误,内部类好象也不行,然后我又试了一下abstract,sealed,override,virtual等几个修饰符也没能达到效果,也不知道是不是我使用的时候出的问题还是怎么回事。
希望各位大侠能够帮忙解答一下,怎么才能达到这样的效果。在此谢过了