电脑故障

位置:IT落伍者 >> 电脑故障 >> 浏览文章

HashTable类


发布日期:2023/5/2
 

//HashTable类表示一个键(Key)/值(Value)对的集合根据指定的键的哈希代码来组织这些键/值对

//示例:

using System;

using SystemCollectionsGeneric;

using SystemText;

using SystemCollections;

using SystemData;

namespace ConsoleApplication

{

public class ContractorTest

{

public static void Main()

{

Hashtable currencies = new Hashtable();

currenciesAdd(US Dollar);

currenciesAdd(Japan Yen);

currenciesAdd(France Euro);

ConsoleWrite(US Currency: {} currencies[US]);

ConsoleReadLine();

}

}

}

//示例:

using System;

using SystemCollectionsGeneric;

using SystemText;

using SystemCollections;

using SystemData;

namespace ConsoleApplication

{

public class ContractorTest

{

public static void Main()

{

student stu = new student();

stuStuid = ;

stuStrname = zhangsan;

student stu = new student();

stuStuid = ;

stuStrname = lisi;

Hashtable ht = new Hashtable();

htAdd(stuStuid stu);

htAdd(stuStuid stu);

//第一种方法遍历集合中元素不通用

//for (int i = ; i < htCount + ; i++)

//{

// student stu = (student)ht[i];

// ConsoleWriteLine(stuStuidToString() + + stuStrname);

//}

//第二种方法遍历集合中元素

IDictionaryEnumerator ide = htGetEnumerator();

while (ideMoveNext())

{

DictionaryEntry destu = (DictionaryEntry)ideCurrent;

//ConsoleWriteLine(destuKeyToString());

student stu = (student)destuValue;

ConsoleWriteLine(stuStuid + + stuStrname);

}

ConsoleReadLine();

}

}

上一篇:Biztalk 开发之架构的发布

下一篇:为DataGrid自定义分页添加自定义导航和分页信息