/// <summary>
/// 學習Directionary
/// </summary>
private void stuDirectionary()
{
//定議一下Dictionary類型
Dictionary<int, string> dDirectionary = new Dictionary<int, string>();
dDirectionary.Add(0, "0000");
dDirectionary.Add(1, "1111");
//獲取key值方法1
foreach (int var in dDirectionary.Keys)
{
int i = var;
}
//獲取key值方法2:用Keys集合轉移到ArrayList,用ArrayList轉出
ArrayList al = new ArrayList(dDirectionary.Keys);
for (int iArray = 0; iArray < al.Count; iArray++)
{
//將獲得每個Value值賦給sDirectionaryValue
string sDirectionaryValue = al[iArray].ToString();
}
//循環得到Dictionary中value的值
for (int iDCount = 0; iDCount < dDirectionary.Count; iDCount++)
{
//將獲得每個Value值賦給sDirectionaryValue
string sDirectionaryValue = dDirectionary[iDCount];
}
}
/// <summary>
/// 學習HashTable
/// </summary>
private void stuHashTable()
{
//定一個Hastable
Hashtable htHastable = new Hashtable();
//填加HastTable值
htHastable.Add(0, "0000");
htHastable.Add(1, "1111");
//獲得HashTable中每個Value值1
foreach (string var in htHastable.Values)
{
//將獲得每個Value值賦給sHtValue
string sHtValue = var;
}
//獲得HashTable中每個Value值2
for (int ihtCount = 0; ihtCount < htHastable.Count; ihtCount++)
{
//將獲得每個Value值賦給sHtValue
string sHtValue = htHastable[ihtCount].ToString();
}
}
/// 學習Directionary
/// </summary>
private void stuDirectionary()
{
//定議一下Dictionary類型
Dictionary<int, string> dDirectionary = new Dictionary<int, string>();
dDirectionary.Add(0, "0000");
dDirectionary.Add(1, "1111");
//獲取key值方法1
foreach (int var in dDirectionary.Keys)
{
int i = var;
}
//獲取key值方法2:用Keys集合轉移到ArrayList,用ArrayList轉出
ArrayList al = new ArrayList(dDirectionary.Keys);
for (int iArray = 0; iArray < al.Count; iArray++)
{
//將獲得每個Value值賦給sDirectionaryValue
string sDirectionaryValue = al[iArray].ToString();
}
//循環得到Dictionary中value的值
for (int iDCount = 0; iDCount < dDirectionary.Count; iDCount++)
{
//將獲得每個Value值賦給sDirectionaryValue
string sDirectionaryValue = dDirectionary[iDCount];
}
}
/// <summary>
/// 學習HashTable
/// </summary>
private void stuHashTable()
{
//定一個Hastable
Hashtable htHastable = new Hashtable();
//填加HastTable值
htHastable.Add(0, "0000");
htHastable.Add(1, "1111");
//獲得HashTable中每個Value值1
foreach (string var in htHastable.Values)
{
//將獲得每個Value值賦給sHtValue
string sHtValue = var;
}
//獲得HashTable中每個Value值2
for (int ihtCount = 0; ihtCount < htHastable.Count; ihtCount++)
{
//將獲得每個Value值賦給sHtValue
string sHtValue = htHastable[ihtCount].ToString();
}
}