How do I use System.Net.ConnectStream?

后端 未结 3 1023
终归单人心
终归单人心 2021-01-27 01:36

I am trying to get my head around some of my predecessors code who, helpfully, has used \'var\' to declare everything.

I have a using statement which is below:



        
3条回答
  •  温柔的废话
    2021-01-27 02:13

    ConnectStream is an internal class, you can't use it explicitly. But it doesn't matter, because you don't need to know that its actual type is ConnectStream: all you need to know is that it's a Stream (the return type declared by GetRequestStream), the actual implementation doesn't really matter.

    If you want to specify the type explicitly, just write it like this:

    using (Stream postStream = request.GetRequestStream())
    {
        postStream.Write(byteData, 0, byteData.Length);
    }
    

    (but it has exactly the same meaning as using var)

提交回复
热议问题