다음은 내가 시도한 것과 무슨 일이 일어 났는지에 대한 성적표입니다.Powershell의 .net 프레임 워크에서 오버로드 된 정적 메서드를 어떻게 호출합니까?
다음 오버레이가 작동하지 않는 이유에 대한 설명과 함께 특정 오버로드를 호출하는 방법을 찾고 있습니다. 대답이 "이 커맨드 릿을 대신 사용해야합니다"또는 "두 번 부름"이라면 대답을 수락하지 않을 때 이해하십시오. 작동
PS C:\> [System.IO.Path]::Combine("C:\", "foo")
C:\foo
PS C:\> [System.IO.Path]::Combine("C:\", "foo", "bar")
Cannot find an overload for "Combine" and the argument count: "3".
At line:1 char:26
+ [System.IO.Path]::Combine <<<< ("C:\", "foo", "bar")
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
PS C:\> [System.IO.Path]::Combine(, "C:\", "foo", "bar")
Missing ')' in method call.
At line:1 char:27
+ [System.IO.Path]::Combine(<<<< , "C:\", "foo", "bar")
+ CategoryInfo : ParserError: (CloseParenToken:TokenId) [], Paren
tContainsErrorRecordException
+ FullyQualifiedErrorId : MissingEndParenthesisInMethodCall
PS C:\> [System.IO.Path]::Combine($("C:\", "foo", "bar"))
Cannot find an overload for "Combine" and the argument count: "1".
At line:1 char:26
+ [System.IO.Path]::Combine <<<< ($("C:\", "foo", "bar"))
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
이 나는 C#에서 할 것입니다 : 파워 쉘은 특정 과부하를 호출 무엇
var foobar = Path.Combine(@"C:\", "foo", "bar");
Console.WriteLine(foobar);
? Path.Combine은 다음 두 가지를 모두 가지고 있습니다 :
public static string Combine (string path1, string path2, string path3);
public static string Combine (params string[] paths);
둘 다 호출 할 수 있습니까, 아니면 하나만 호출 할 수 있습니까? 분명히이 특별한 경우에는 그 차이를 말하기 어렵습니다.
이러한 오버로드는 .Net 4.0에서 새로 추가되었습니다. Powershell이 .Net 4.0에서 실행되고 있습니까? '[environment] :: version'을 사용하면 CLR 버전을 얻을 수 있습니다. – Lee