英語で読む

次の方法で共有


NegotiateStream.CanRead プロパティ

定義

基になるストリームが読み取り可能かどうかを示す Boolean 値を取得します。

C#
public override bool CanRead { get; }

プロパティ値

認証が行われており、基になるストリームが読み取り可能な場合は true。それ以外の場合は false

次のコード例では、このプロパティの値を表示する方法を示します。

C#
 static void DisplayStreamProperties(NegotiateStream stream)
{
     Console.WriteLine("Can read: {0}", stream.CanRead);
     Console.WriteLine("Can write: {0}", stream.CanWrite);
     Console.WriteLine("Can seek: {0}", stream.CanSeek);
     try
     {
         // If the underlying stream supports it, display the length.
         Console.WriteLine("Length: {0}", stream.Length);
     } catch (NotSupportedException)
     {
             Console.WriteLine("Cannot get the length of the underlying stream.");
     }

     if (stream.CanTimeout)
     {
         Console.WriteLine("Read time-out: {0}", stream.ReadTimeout);
         Console.WriteLine("Write time-out: {0}", stream.WriteTimeout);
     }
}

注釈

認証が成功した場合、このプロパティは基になるストリームで プロパティを CanRead 呼び出すことによって返される値を返します。 基になるストリームは、 クラスの NegotiateStream インスタンスを作成するときに指定されます。

適用対象

製品 バージョン
.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 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 2.0, 2.1