我想要一个散列表,其中包含一个班级号和一个与所有学生相关联的数组 [英] I want a Hash Table, that contains a Class Number, and an associated array with all Students
本文介绍了我想要一个散列表,其中包含一个班级号和一个与所有学生相关联的数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
基本上,我想创建一个哈希表,如下所示:
{" = $ ClassNumber; " = @($ Student1,$ Student2,... $ Studentx)}
我希望能够添加带有学生的ClassNumber,然后继续一次将Student一次添加到Student数组中,同时保留相同的ClassNumber.即
$ hash = {" = $ ClassNumber; " = @($ Student1)}
现在添加Student2,因此它看起来像
{" = $ ClassNumber; " = @($ Student1,$ Student2)}
直到我有所有学生,然后添加一个新的班级编号和关联的学生.
我还希望能够按如下方式访问每个数据库:
$ hash [" ] [" ] [ 1 ]
$ hash [" ] [ 2 ]
$ hash [" ] [ 0 ]
$ hash [" ] [ 1 ]
$ hash [" ] [ 2 ]
$ hash [" ] [ 3 ]
解决方案
ClassNumber; " = @(
Student1,
学生2,...
Basically, I would like to create a hash table that looks like:
{"ClassNumber" = $ClassNumber; "Student" = @($Student1,$Student2,...$Studentx)}
I would like to be able to add the ClassNumber, with a Student, then continue to add Students to the Student array one at a time, while leaving the same ClassNumber. Ie,
$hash = {"ClassNumber" = $ClassNumber; "Students" = @($Student1)}
now add Student2, so it looks like
{"ClassNumber" = $ClassNumber; "Students" = @($Student1,$Student2)}
until I have all Students, then add a new ClassNumber and associated Students.
I would also like to be able to access each one as follows:
$hash["Class1"][0]
$hash["Class1"][1]
$hash["Class1"][2]
$hash["Class2"][0]
$hash["Class2"][1]
$hash["Class2"][2]
$hash["Class2"][3]
解决方案
ClassNumber; "Student" = @(
Student1,
Student2,...
这篇关于我想要一个散列表,其中包含一个班级号和一个与所有学生相关联的数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文