Skip to content

Instantly share code, notes, and snippets.

@davidfowl
Created May 8, 2017 09:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidfowl/272e9f0f28ee10102d4113d212fc4672 to your computer and use it in GitHub Desktop.
Save davidfowl/272e9f0f28ee10102d4113d212fc4672 to your computer and use it in GitHub Desktop.
Stream throws
using System;
using System.IO;
namespace ConsoleApp19
{
class Program
{
static void Main(string[] args)
{
var ms = new MemoryStream();
var source = new MyStream();
source.CopyTo(ms);
}
}
public class MyStream : Stream
{
public override bool CanRead => false;
public override bool CanSeek => false;
public override bool CanWrite => true;
public override long Length => 0;
public override long Position { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override void Flush()
{
}
public override int Read(byte[] buffer, int offset, int count)
{
return 0;
}
public override long Seek(long offset, SeekOrigin origin)
{
return 0;
}
public override void SetLength(long value)
{
}
public override void Write(byte[] buffer, int offset, int count)
{
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment