1
在powershell中有一种将散列表转换为System.Version的方法,我得到的错误是无法转换类型为“System.Collections.Hashtable”的“System.Collections.Hashtable”值“键入”System.Version“。将Hashtable转换为System.Version
例 在我的foreach循环,我添加了两个变量键和值dbDictionary
$ dbDictionary.Add($ dbChangesfiles,$线)
然后我想打开将dbDictionary转换为System.Version,这样我就可以将其引用到其他两个已转换为System.Version的变量中。
$ dbDictionaryAsVersion = [System.Version] $ dbDictionary
任何帮助,将不胜感激
医生给你开,欢呼声。 – Lewis 2013-03-01 11:46:16
请注意,在hastables中缺少[PSv3中的'[[[ordered]'](http://arcanecode.com/2012/06/04/powershell-v3-ordered-hashtables/))值不能保证顺序你添加它们,所以'@ {A = 1; B = 2}'可以返回'1.2'或'2.1'。 – 2013-03-09 15:55:59
正确,但System.Version的默认格式将覆盖该格式。 – 2013-03-10 12:21:17