Consider the following function:
private int GetSomethingFromFile(FileStream fs)
{
using (BinaryReader br = new BinaryReader(fs))
{
fs.Seek(0, SeekOrigin.Begin);
return br.ReadInt32();
}
}
A FileStream object is passed in as a parameter and a BinaryReader is declared with a using statement. When I try to use that FileStream object, after calling this function, it throws a System.ObjectDisposedException. Why is that FileStream object being disposed of along with the BinaryReader object?