社区
C#
帖子详情
请问,如何得到ArrayList中的某一个元素的值?
supere
2003-10-17 08:47:37
请问,如何得到ArrayList中的某一个元素的值?
...全文
1170
17
打赏
收藏
请问,如何得到ArrayList中的某一个元素的值?
请问,如何得到ArrayList中的某一个元素的值?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
17 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
poetc
2003-10-17
打赏
举报
回复
跟数组一样用呀。
runsoft
2003-10-17
打赏
举报
回复
接分,经管我不懂。呵呵。
gaisylly
2003-10-17
打赏
举报
回复
这是foreach的
using System;
using System.Collections;
namespace ConsoleApplication1
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
ArrayList arraylist = new ArrayList();
arraylist.Add("Hello");
arraylist.Add("World");
arraylist.Add("!");
foreach (string s in arraylist)
{
Console.Write( "{0}\n", s );
}
}
}
}
haoliqi
2003-10-17
打赏
举报
回复
up
gaisylly
2003-10-17
打赏
举报
回复
再或者
using System;
using System.Collections;
namespace ConsoleApplication1
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
ArrayList arraylist = new ArrayList();
arraylist.Add("Hello");
arraylist.Add("World");
arraylist.Add("!");
for (int i=0;i<arraylist.Count;++i)
{
Console.Write( "{0}\n", arraylist[i] );
}
}
}
}
gaisylly
2003-10-17
打赏
举报
回复
或者
using System;
using System.Collections;
namespace ConsoleApplication1
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
ArrayList arraylist = new ArrayList();
arraylist.Add("Hello");
arraylist.Add("World");
arraylist.Add("!");
System.Collections.IEnumerator Enumerator = arraylist.GetEnumerator();
while (Enumerator.MoveNext())
{
Console.Write( "{0}\n", Enumerator.Current );
}
}
}
}
rgbcn
2003-10-17
打赏
举报
回复
接分
Stevetan81
2003-10-17
打赏
举报
回复
xxx[int i]
or xxx["memberName"]
gaisylly
2003-10-17
打赏
举报
回复
FOR EACH IN
cqnimin
2003-10-17
打赏
举报
回复
呵呵,接分:)
kuangsha007
2003-10-17
打赏
举报
回复
^_^ ing,既然解决了就好。
shajie
2003-10-17
打赏
举报
回复
既然已经解决了,就接分吧,:)
antshome
2003-10-17
打赏
举报
回复
XXX[0]
可能还需要强制类型转换一下
topsonstar
2003-10-17
打赏
举报
回复
用索引
supere
2003-10-17
打赏
举报
回复
ArrayList没有这个方法吧
allen1981813
2003-10-17
打赏
举报
回复
SetValue方法
supere
2003-10-17
打赏
举报
回复
晕!已经解决!送分给第一个回答的人吧
Java进阶课程系列之
ArrayList
集合底层源码实战分析
ArrayList
允许空
值
和重复元素,当往
ArrayList
中
添加的元素数量大于其底层数组容量时,其会通过扩容机制重新生成一个更大的数组。另外,由于
ArrayList
底层基于数组实现,所以其可以保证在 O(1) 复杂度...
java
arraylist
min_如何在
ArrayList
中
找到最小
值
以及索引号? (Java)
如何在
ArrayList
中
找到最小
值
以及索引号? (Java)我需要在Java的
arraylist
中
获取最小
值
的索引
值
。 我的
arraylist
包含多个浮点数,我正在尝试一种获取最小浮点数的索引号的方法,以便可以在代码的其他地方使用该索引号。 我是一个初学者,所以请不要讨厌我。 谢谢!user2130496 asked 2020-01-17T11:06:44Z6个解决方案93 votes您可以使用...
arraylist
替换 java_如何替换java
中
的
ArrayList
元素的现有
值
[复制]
问题这个问题在这里已有答案:如何更新
ArrayList
中
某个位置的元素? [重复] 5个答案我仍然是java编程的新手,我正在尝试使用此代码更新Array列表的现有
值
public static void main(String[] args){List list = new
ArrayList
();list.add( "Zero" );list.add( "One" );list.add( "Tw...
遍历
ArrayList
并移除一
个元素
前言 这是一个比较经典的面试题,相信也会有不少人遇到,今天就在此记录一下,写了两种方式供大家参考。 方式一 在for循环
中
删除元素,倒序遍历
ArrayList
能够有效防止漏删,这里大家可能会有疑问了?假设按照从0到size-1下标来删那么如果有相邻的两
个元素
是一样的,删除了第一个,此时数组长度会-1并且所有元素往前移动一位,那么第二个就移动到第一
个元素
的位置了,此时控
值
for循环的下标i已经+1了等于直接就跳过了第二个重复元素,倒叙就不会出现此类情况了。 List<String> strs =
Java
中
如何获取一
个元素
在
ArrayList
的索引位置呢?
Java
中
获取一
个元素
在
ArrayList
的索引位置
C#
110,532
社区成员
642,574
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章