Powershell Add-Type - 添加字典/ hashtable类型的成员

时间:2016-08-29 09:49:03

标签: class powershell dictionary hashtable add-type

我正在尝试在PowerShell中添加自定义类型,如下所示:

Add-Type @'
public class MyType {
    public string name;
    public string type;
    public hashtable data;
    public string category;
}
'@

但是,类型哈希表,字典不存在。我已经四处寻找有关此事的例子,但找不到任何例子。

可能会添加,我不想使用Add-Member。

有什么想法吗?

/帕特里克

1 个答案:

答案 0 :(得分:1)

2件事:

  1. 大写" Hashtable",C#区分大小写
  2. 添加InputStream con = session.getClass().getResourceAsStream("C:/pqrs.properties"); if(con== null) { System.out.println("FLAG FILE NOT FOUNDFIND NOT FOUND!!!!!!!!!!!"); }else { System.out.println("FLAG FILE FOUND !!!!!!!!FIND FOUND"); } Properties ff = new Properties(); ff.load(con); 语句,以便编译器可以解析完整类型名称
  3. try this..
    
              <script>   
    
                      var app = angular.module("myApp", [])
    
                    .controller("myControllerSubmit", function ($scope, $http) {
    
                        $scope.submit = function () {
                              var Employee = { empID: $scope.empId, Name: $scope.empName, Gender: $scope.empGender }
                             $http.post( 'http://localhost:58365/home/saveEmpData', json.Stringify(Employee) ).success(function (response,status,headers,config) {
                              $scope.data1 = response.data;
                            }).error (function(){
                                  alert("error")
                              });
                        }
                    })
    
                     </script>
    
相关问题