// Create a new SslStream object SslStream sslStream = new SslStream(tcpClient.GetStream(), false); try { // Do SslStream operations } finally { // Dispose the SslStream object sslStream.Dispose(); }
// Create a new SslStream object SslStream sslStream = new SslStream(tcpClient.GetStream(), false); using (sslStream) { // Do SslStream operations }In this example, the using statement is used with the SslStream object to ensure that the Dispose method is called automatically when the object is no longer used. Package/Library: The System.Net.Security namespace is a part of the .NET Framework Class Library.