Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

244
Vistas
What exactly is/means "System.IO.Stream+NullStream"?

I am currently experimenting to find the proper way of creating an HTTP context for unit testing purposes. While examining the stream types created, I was surprised that the following returns a type of System.IO.Stream+NullStream.

var context = new DefaultHttpContext();

var requestBodyType = context.Request.Body.GetType().FullName; 
var responseBodyType = context.Response.Body.GetType().FullName; 

If the test case requires it, I'd simply replace the stream with a MemoryStream and then act upon it accordingly.

var memoryStream = new MemoryStream();
var context = new DefaultHttpContext(); 
context.Response.Body = memoryStream;

So far so good. But what exactly is System.IO.Stream+NullStream? I would have expected to find a type of NullStream in the documentation, but couldn't find such a thing.

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

It's an internal type.

It sub-classes Stream, and is exposed as Stream.Null.

As you can see from the implementation, it just throws away any data written to it, and doesn't return any data if asked.

over 4 years ago · Santiago Trujillo Denunciar

0

The hierarchy for System.IO.Stream+NullStream looks like this

public abstract class Stream {

    private sealed class NullStream {
    
    }
    
}

The + means it's a nested child class of Stream

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda