System.IO.BinaryReader.ReadInt32 C# (CSharp) Method

ReadInt32() public method

public ReadInt32 ( ) : int
return int
        public virtual int ReadInt32()
        {
            if (_isMemoryStream)
            {
                if (_stream == null)
                {
                    throw new ObjectDisposedException(null, SR.ObjectDisposed_FileClosed);
                }

                // read directly from MemoryStream buffer
                MemoryStream mStream = _stream as MemoryStream;
                Debug.Assert(mStream != null, "_stream as MemoryStream != null");

                return mStream.InternalReadInt32();
            }
            else
            {
                FillBuffer(4);
                return (int)(_buffer[0] | _buffer[1] << 8 | _buffer[2] << 16 | _buffer[3] << 24);
            }
        }

Usage Example

Example #1
1
        public Boolean fromFile(String path)
        {
            FileStream fs = new FileStream(path, FileMode.Open);
            BinaryReader reader = new BinaryReader(fs);
            try
            {
                String h = reader.ReadString();
                float v = BitConverter.ToSingle(reader.ReadBytes(sizeof(float)), 0);
                drawFloorModel = reader.ReadBoolean();
                showAlwaysFloorMap = reader.ReadBoolean();
                lockMapSize = reader.ReadBoolean();
                mapXsize = reader.ReadInt32();
                mapYsize = reader.ReadInt32();

                //edgeXのxはmapX-1
                //yはmapYsize

                return true;

            }
            catch (EndOfStreamException eex)
            {
                //握りつぶす
                return false;
            }
            finally
            {
                reader.Close();
            }
        }
All Usage Examples Of System.IO.BinaryReader::ReadInt32