对hashtable循环赋值 一个数组int A[10],可不可以用for循环,对hashtable循环赋值,使得key = i,value = A[i].应该怎么写呢?我貌似没找到这样的赋值 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 List<int> lt = new List<int>(); lt.Add(1); lt.Add(2); lt.Add(3); List<int> new_lt = new List<int>(); for (int i = 0; i < lt.Count; i++) { for (int j = 0; j < lt.Count; j++) { if (lt[i] != lt[j] && lt[i] < lt[j]) { new_lt.Add(lt[i] + lt[j]); } } hashtable能不能循环赋值呢?我需要用到key和value拜托了,想想办法吧 完全可以实现,在控制台下简单写了个实现代码,以供参考:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Collections;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { int[] arr=new int[10]; for(int i=0;i<arr.Length;i++) { arr[i]=i*10+i; } Hashtable hash = new Hashtable(); for(int i=0;i<arr.Length;i++) { hash.Add(i, arr[i]); } foreach (DictionaryEntry item in hash) { Console.WriteLine("Key:"+item.Key+"\t\tValue:"+item.Value); } Console.ReadKey(); } }} 关于获取网页提交的内容 c#修改完dataGridView怎么保存回去 C#基础问题?? dataGridView中超链接问题 C#的书 有关一个项目的讨论,做过同一城市连锁店的会员管理系统的请进!!!急切中, 用nHibernate1.0.1.0 请问怎么用SendKeys 发送shift+tab组合键呢?? 不相信这里没有高手(关于AD)!!! C#中类似c语言的#define怎么写? 关于C#属性 各位大侠,用VS2008制作网页,预览时图片正常显示,但一运行,在浏览器图片就不显示啦,这是为什么呢?(图片是gif格式
lt.Add(1);
lt.Add(2);
lt.Add(3);
List<int> new_lt = new List<int>();
for (int i = 0; i < lt.Count; i++)
{
for (int j = 0; j < lt.Count; j++)
{
if (lt[i] != lt[j] && lt[i] < lt[j])
{
new_lt.Add(lt[i] + lt[j]);
}
}
我需要用到key和value
拜托了,想想办法吧
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] arr=new int[10];
for(int i=0;i<arr.Length;i++)
{
arr[i]=i*10+i;
}
Hashtable hash = new Hashtable();
for(int i=0;i<arr.Length;i++)
{
hash.Add(i, arr[i]);
}
foreach (DictionaryEntry item in hash)
{
Console.WriteLine("Key:"+item.Key+"\t\tValue:"+item.Value);
}
Console.ReadKey();
}
}
}