问一个数组的问题和问一个代码共享的问题
问题一:数据库里面存放怎样的数据更容易放在数组里呢,我的是Access数据库的文本字段,存成 8,22,32,48, 这样的,但是这样放进数组里会出错。怎样做可以直接放入数组里面呢?
问题二:新建一个项目,写了个config.cs ,在config.cs里面作了个连接数据库的 ConnDB.Open();我现在又新建了一个目录为Forum,在Forum里面有个default.aspx,问题就是在default.aspx里面怎样调用这个上一级目录的ConnDB.Open();呀。同一目录就可以,但是不同目录会出错的,要怎样做?
问题点数:100、回复次数:6Top
1 楼saucer(思归)回复于 2003-09-04 09:58:23 得分 0
1.
YourArrayTable
Array_ID number
Array_Value number
1 8
1 22
1 32
1 48
2 1
2 3
2 4
2. compile config.cs into a dll and copy it to the bin subdirectory of your virtual directory and call it freelyTop
2 楼saucer(思归)回复于 2003-09-04 10:02:21 得分 0
1.
YourArrayTable
Array_ID number
Array_Value number
1 8
1 22
1 32
1 48
2 1
2 3
2 4
2. compile config.cs into a dll and copy it to the bin subdirectory of your virtual directory and call it freelyTop
3 楼hgknight(江雨.net)回复于 2003-09-04 10:02:51 得分 5
1.你是怎么放的,出什么错
2.using yourNameSpace;
实例化该类Top
4 楼saucer(思归)回复于 2003-09-04 10:04:33 得分 0
1.
YourArrayTable
Array_ID number
Array_Value number
1 8
1 22
1 32
1 48
2 1
2 3
2 4
2. compile config.cs into a dll and copy it to the bin subdirectory of your virtual directory and call it freelyTop
5 楼weki(小李)回复于 2003-09-04 10:07:47 得分 0
问题一的:
aaa="8,22,32,48,";//其实这里是读出一个字段值
int[] MyArr= new int[aaa] {int.Parse(aaa)}; //我试过的方法,但是有错。:(
for (int i=0; i < MyArr.Length; i++)
{
Response.Write(MyArr[ i ]+"<br>");
}
问题二的:
能不能给个例子看看呀。我很是笨..........:( 学了net很久还是在游呀游的Top
6 楼coolpine(岁寒一友)回复于 2003-09-04 10:14:09 得分 5
对于第一个方法,你还是把四个数字分别存到数组里面吧
用过二维数组,或者数组的数组好了Top
7 楼saucer(思归)回复于 2003-09-04 10:15:22 得分 45
string aaa="8,22,32,48,";
string[] alist = aaa.Split(',');
int[] MyArr = new int[alist.Length];
for (int i=0; i < MyArr.Length; i++)
{
MyArr[i] = Int32.Parse(alist[i].Trim());
Response.Write(MyArr[i]+"<br>");
}
Top
8 楼chnking(kent)回复于 2003-09-04 10:26:35 得分 45
问题一的:
string aa="8,22,32,48,";//其实这里是读出一个字段值
string[] aaa = aa.Split(',');
for (int i=0; i < aaa.Length; i++)
{
Response.Write(aaa[i]+"<br>");
}
问题二:
写了个config.cs,其中有个config的类,这个类有些public的方法,比如这个类所在的名称控件为:WebApplication1。
又新建了一个目录为Forum,在Forum里面有个default.aspx,这个page的缺省名称空间是:WebApplication1.Forum,在default.aspx要引用上述的config的类,应该在文件头部引用config的类的名称空间:
using WebApplication1;
然后实例化config类:
config myconfig = new config();
要是没有引用config类的名称空间可以这样声明config类:
WebApplication1.config myconfig = new WebApplication1.config();Top
9 楼chnking(kent)回复于 2003-09-04 10:27:23 得分 0
问题一的:
string aa="8,22,32,48,";//其实这里是读出一个字段值
string[] aaa = aa.Split(',');
for (int i=0; i < aaa.Length; i++)
{
Response.Write(aaa[i]+"<br>");
}
问题二:
写了个config.cs,其中有个config的类,这个类有些public的方法,比如这个类所在的名称控件为:WebApplication1。
又新建了一个目录为Forum,在Forum里面有个default.aspx,这个page的缺省名称空间是:WebApplication1.Forum,在default.aspx要引用上述的config的类,应该在文件头部引用config的类的名称空间:
using WebApplication1;
然后实例化config类:
config myconfig = new config();
要是没有引用config类的名称空间可以这样声明config类:
WebApplication1.config myconfig = new WebApplication1.config();Top




