C
C# Learner
class Foo
{
NetworkStream stream;
public void Bar()
{
TcpClient client = Something.GetTcpClient();
stream = client.GetStream();
}
}
Do I also need to hold a reference to /client/ to stop the object
referenced by /this.stream/ from being collected?
I'd assume so, but wanted to ask in case I'm missing something to do
with how TcpClient and NetworkStream work together here.
{
NetworkStream stream;
public void Bar()
{
TcpClient client = Something.GetTcpClient();
stream = client.GetStream();
}
}
Do I also need to hold a reference to /client/ to stop the object
referenced by /this.stream/ from being collected?
I'd assume so, but wanted to ask in case I'm missing something to do
with how TcpClient and NetworkStream work together here.