英語で読む

次の方法で共有


Uri.IsLoopback プロパティ

定義

指定した Uri によってローカル ホストが参照されているかどうかを示す値を取得します。

C#
public bool IsLoopback { get; }

プロパティ値

true これが Uri ローカル ホストを参照する場合は 。それ以外の場合 falseは 。

例外

このインスタンスは相対 URI を表します。このプロパティは、絶対 URI でのみ有効です。

次の例では、 インスタンスを Uri 作成し、ローカル ホストを参照するかどうかを決定します。

C#
Uri uriAddress2 =  new Uri("file://server/filename.ext");
Console.WriteLine(uriAddress2.LocalPath);
Console.WriteLine("Uri {0} a UNC path", uriAddress2.IsUnc ? "is" : "is not");
Console.WriteLine("Uri {0} a local host", uriAddress2.IsLoopback ? "is" : "is not");
Console.WriteLine("Uri {0} a file", uriAddress2.IsFile ? "is" : "is not");
// The example displays the following output:
//    \\server\filename.ext
//    Uri is a UNC path
//    Uri is not a local host
//    Uri is a file

注釈

IsLoopback は、 true このインスタンスの作成時に指定された URI が 127.0.0.1、ループバック、または localhost であった場合、または URI でホスト情報 (file:///c:Dir/file.txt など) が指定されていない場合に を返します。 その他のすべての URI は を返します false

適用対象

製品 バージョン
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0