C# BinaryReader.ReadChars的代码示例
通过代码示例来学习C# BinaryReader.ReadChars方法
通过代码示例来学习编程是非常高效的。
1. 代码示例提供了一个具体而直观的学习环境,使初学者能够立即看到编程概念和语法的实际应用。
2. 通过分析和模仿现有的代码实例,初学者可以更好地理解编程逻辑和算法的工作原理。
3. 代码实例往往涵盖了多种编程技巧和最佳实践,通过学习和模仿这些实例,学习者可以逐步掌握如何编写高效、可读性强和可维护的代码。这对于初学者来说,是一种快速提升编程水平的有效途径。
BinaryReader.ReadChars是C#的System.IO命名空间下中的一个方法, 小编为大家找了一些网络大拿们常见的代码示例,源码中的BinaryReader.ReadChars() 已经帮大家高亮显示了,大家可以重点学习BinaryReader.ReadChars() 方法的写法,从而快速掌握该方法的应用。
BinaryReader.ReadChars的代码示例1 - GetNextChunk()
using System.IO; private AiffChunk GetNextChunk(BinaryReader binaryReader) { try { var chars = binaryReader.ReadChars(4); if (chars.Length != 4) throw new EndOfStreamException(); var chunkId = new string(chars); switch (chunkId) { case "COMM": return new CommonChunk(binaryReader); case "SSND": return new SoundDataChunk(binaryReader); case "FVER": return new FormatVersionChunk(binaryReader); case "\0\0\0\0": return null; default: return new AiffChunk(binaryReader, chunkId); } } catch (EndOfStreamException) { return null; } }
开发者ID:filoe,项目名称:cscore,代码行数:30,代码来源:AiffChunkContainer.cs
在GetNextChunk()方法中,BinaryReader的代码示例类中的ReadChars的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
BinaryReader.ReadChars的代码示例2 - InitializeByStream()
using System.IO; ///
/// Initializes the properties of the /// The stream which contains the metadata. protected override unsafe void InitializeByStream(Stream stream) { //http://flac.sourceforge.net/format.html#metadata_block_streaminfo var reader = new BinaryReader(stream, Encoding.ASCII); try { MinBlockSize = reader.ReadInt16(); MaxBlockSize = reader.ReadInt16(); } catch (IOException e) { throw new FlacException(e, FlacLayer.Metadata); } const int bytesToRead = (240 / 8) - 16; byte[] buffer = reader.ReadBytes(bytesToRead); if (buffer.Length != bytesToRead) { throw new FlacException(new EndOfStreamException("Could not read StreamInfo-content"), FlacLayer.Metadata); } fixed (byte* b = buffer) { var bitreader = new FlacBitReader(b, 0); MinFrameSize = (int)bitreader.ReadBits(24); MaxFrameSize = (int)bitreader.ReadBits(24); SampleRate = (int)bitreader.ReadBits(20); Channels = 1 + (int)bitreader.ReadBits(3); BitsPerSample = 1 + (int)bitreader.ReadBits(5); TotalSamples = (long)bitreader.ReadBits64(36); Md5 = new String(reader.ReadChars(16)); } }by reading them from the . ///
开发者ID:filoe,项目名称:cscore,代码行数:38,代码来源:FlacMetadataStreamInfo.cs
在InitializeByStream()方法中,BinaryReader的代码示例类中的ReadChars的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
本文中的BinaryReader.ReadChars方法示例由csref.cn整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。