如何在Powershell哈希表中获取特定值的名称?

时间:2015-12-16 17:47:44

标签: powershell powershell-v2.0 powershell-v3.0

如果我有像...这样的哈希表。

$theHash = @{"dog"="mean"; "cat"="nice";"bird"="annoying"}

我可以通过以下方式获取值的关键字:

$theHash."dog"

我该如何反过来?我想提出类似的东西,"意思是"得到"狗"作为输出?因此,如果我只知道"意思是",我该如何从中得到狗?

1 个答案:

答案 0 :(得分:4)

String from = request.getParameter("from");
        String to = request.getParameter("to");
        String step = request.getParameter("step");

        **String convert = request.getParameter("convert");**


        response.setContentType("text/html");
        response.setCharacterEncoding("UTF-8");
        PrintWriter out = response.getWriter();

        out.println("convert: " + convert);


        int fromCount = 0;
        int toCount = 0;
        int stepCount=0;

        boolean badValues = false;
        try {
             fromCount = Integer.parseInt(from);
             toCount = Integer.parseInt(to);
             stepCount = Integer.parseInt(step);

            } catch (NumberFormatException e) {
             badValues = true;
             }

        if (badValues) {
            out.println("<strong style=\"color:red\">All Fields should be Integer</strong>"
                    + " <br>\n"
                    + "<a href='../FormDemo.html'>Back to the form</a>");
        }
            else
              **if (convert=="cf") {
             printTable(out, fromCount, toCount, stepCount);
        }
             else
            printTable2(out, fromCount, toCount, stepCount);
             }**