string 为什么我不能将 ToUpper() 应用于 OwnerNode?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16963511/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why can't I apply ToUpper() to an OwnerNode?
提问by tkrn
This works:
这有效:
Output "Cluster Group: ""$($Group.Name)"", Current Owner: $($Group.OwnerNode), Current State: $($Group.State)"
This does not work:
这不起作用:
Output "Cluster Group: ""$($Group.Name)"", Current Owner: $($Group.OwnerNode.ToUpper()), Current State: $($Group.State)"
With an error of this:
有这样的错误:
Method invocation failed because [Microsoft.FailoverClusters.PowerShell.ClusterNode] doesn't contain a method named 'ToUpper'.
Any ideas on how to get this to string from the output of the Get-ClusterGroup string to upper case?
关于如何将其从 Get-ClusterGroup 字符串的输出转换为大写的任何想法?
回答by Shay Levy
ToUpper() is a string method and OwnerNode is probably not a string. Call the ToString() method before calling ToUpper().
ToUpper() 是一个字符串方法,而 OwnerNode 可能不是一个字符串。在调用 ToUpper() 之前调用 ToString() 方法。
$($Group.OwnerNode.ToString().ToUpper())