NetworkStream.Writeable 属性  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个值,该值指示 NetworkStream 是否可写入数据。
protected:
 property bool Writeable { bool get(); void set(bool value); };protected bool Writeable { get; set; }member this.Writeable : bool with get, setProtected Property Writeable As Boolean属性值
如果数据可写入该流,则为 true;否则,为 false。 默认值是 true。
示例
在下面的代码示例中 CanCommunicate , 属性检查 Writeable 属性以确定 是否 NetworkStream 可写。
using System;
using System.Net;
using System.Net.Sockets;
public class MyNetworkStream_Sub_Class : NetworkStream
{
    public MyNetworkStream_Sub_Class(Socket socket, bool ownsSocket) :
        base(socket, ownsSocket)
    {
    }
    // You can use the Socket method to examine the underlying Socket.
    public bool IsConnected
    {
        get
        {
            return this.Socket.Connected;
        }
    }
    public bool CanCommunicate
    {
        get
        {
            if (!this.Readable | !this.Writeable)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
    }
Public Class MyNetworkStream_Sub_Class
   Inherits NetworkStream
   
   
   Public Sub New(socket As Socket, ownsSocket As Boolean)
      MyBase.New(socket, ownsSocket)
   End Sub
   
   ' Suppose you wanted a property for determining if Socket is connected. You can use
   ' the protected method 'Socket' to return underlying Socket.
   
   Public ReadOnly Property IsConnected() As Boolean
      Get
         Return Me.Socket.Connected
      End Get
   End Property
   
   ' You could also use public NetworkStream methods 'CanRead' and 'CanWrite'.
   
   Public ReadOnly Property CanCommunicate() As Boolean
      Get
         If Not Me.Readable Or Not Me.Writeable  Then
            Return False
         Else
            Return True
         End If
      End Get
   End Property
    
   Public Shared Sub DoSomethingSignificant()
   End Sub
    ' Do something significant in here
注解
必须从 NetworkStream 类派生才能使用 Writeable 属性。 如果 Writeable 为 true, NetworkStream 则允许调用 Write 方法。 还可以通过检查可公开访问CanWrite的属性来确定 是否NetworkStream可写。
属性 Writeable 是在初始化 时 NetworkStream 设置的。