C#ArrayList !!!! [英] C# ArrayList !!!!
问题描述
HI,
我创建了一个ArrayList数组。
ArrayList arraylist = new ArrayList [7];
和他们一起帮助他们空间
for(int index = 0; index< arraylist.Length; index ++)
{
arraylist [index] = new ArrayList( );
}
我保存了一些值。现在我想访问arraylist [2]的索引号3,为此我使用语法
str =((String)values [g] .Item(j).ToString()) ;
但是它给出了以下错误
''System.Collections.ArrayList''不包含''Item'的定义'
>
请以正确的方式指导我
I have created an array of ArrayList.
ArrayList arraylist=new ArrayList[7];
and them assin them the space
for( int index=0; index<arraylist.Length; index++ )
{
arraylist[ index ] = new ArrayList();
}
THen I save some values in it. Now I want to access index number 3 of arraylist[2] and for this purpose i have use the syntax
str=(( String )values[ g ].Item( j ).ToString());
but it gives the following error
''System.Collections.ArrayList'' does not contain a definition for ''Item''
Kindly guide me in a right way
推荐答案
您是否还可以发布一个如何将值存储到其中的示例。
可能是关键。
欢呼
Could you also post an example of how you are storing values into it.
that might be the key.
cheers
你能否发表一个例子,说明你是怎样的将值存入其中。
可能是关键。
欢呼
Could you also post an example of how you are storing values into it.
that might be the key.
cheers
我使用的代码是用于存储arraylist中的值,因为
为(int b = 0; b< col_count; b ++)
{
name = typ2 [ b]的ToString(); // typ2是另一个运行良好的数组
if(name.Equals(" String")|| name.Equals(" VARCHAR")|| na me.Equals(" CHAR" ;)|| name.Equals(" Text"))
{
string pick =" ab" ;; // ab可以是应该在arraylist上添加的任何字符串
values [b] .Add(pick);
}
现在我正在读取arraylist中的值,如下(
)(strsql.Equals(" VARCHAR(100)"))
{
string str =((String)values [g] .Item(j));
}
在java中我做了同样的事情follwing
string str =((String)values [g] .get(j));
并且它不会给我任何错误。
但是在C#的情况下,它给出的消息是arraylist没有Item的定义
请以正确的方式指导我我非常不安这个问题。
I have use the code as under to store values in arraylist as under
for(int b=0;b<col_count;b++)
{
name=typ2[b].ToString(); // typ2 is another array which is working well
if (name.Equals("String")||name.Equals("VARCHAR")||na me.Equals("CHAR")||name.Equals("Text"))
{
string pick="ab "; // ab can be any string that should be added on arraylist
values[b].Add(pick);
}
Now I am reading values from arraylist as under
if(strsql.Equals("VARCHAR(100)"))
{
string str=(( String )values[ g ].Item( j ));
}
In java I have done the same thing with follwing
string str=(( String )values[ g ].get( j ));
and it doesn''t give me any error.
But in case of C# it gives message that "arraylist has no definition of Item"
Please guide me in a right way I am very disturbed due to this problem.
你的数组声明是不是应该是
Wasn''t your array declaration supposed to be
这篇关于C#ArrayList !!!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!