C# TextReader.ReadLine的代码示例

TextReader.ReadLine方法的主要功能描述

通过代码示例来学习C# TextReader.ReadLine方法

通过代码示例来学习编程是非常高效的。
1. 代码示例提供了一个具体而直观的学习环境,使初学者能够立即看到编程概念和语法的实际应用。
2. 通过分析和模仿现有的代码实例,初学者可以更好地理解编程逻辑和算法的工作原理。
3. 代码实例往往涵盖了多种编程技巧和最佳实践,通过学习和模仿这些实例,学习者可以逐步掌握如何编写高效、可读性强和可维护的代码。这对于初学者来说,是一种快速提升编程水平的有效途径。


TextReader.ReadLine是C#的System.IO命名空间下中的一个方法, 小编为大家找了一些网络大拿们常见的代码示例,源码中的TextReader.ReadLine() 已经帮大家高亮显示了,大家可以重点学习TextReader.ReadLine() 方法的写法,从而快速掌握该方法的应用。

TextReader.ReadLine的代码示例1 - RawReadFirstLinesArray()

    using System.IO;

        /// 
        /// Shortcut method to read the first n lines of a text file as array.
        /// 
        /// The text reader name
        /// The number of lines to read.
        /// The first n lines of the file.
        private static string[] RawReadFirstLinesArray(TextReader stream, int lines)
        {
            var res = new List(lines);
            for (int i = 0; i < lines; i++)
            {
                string line = stream.ReadLine();
                if (line == null)
                    break;
                else
                    res.Add(line);
            }

            return res.ToArray();
        }
    

开发者ID: MarcosMeli,   项目名称: FileHelpers,   代码行数: 22,   代码来源: SmartFormatDetector.cs

在MarcosMeli提供的RawReadFirstLinesArray()方法中,该源代码示例一共有22行, 其中使用了TextReader.ReadLine()1次, 并且小编将这些方法高亮显示出来了,希望对您了解TextReader.ReadLine()有帮助。 如果您觉得有帮助的话,请帮忙点赞或转发。
该代码示例的点赞次数为3, 点赞数越大, 从某种程度说明这个示例对了解TextReader.ReadLine()可能更有帮助。

TextReader.ReadLine的代码示例2 - Parse()

    using System.IO;

        /// 
        ///     Parses a string containing valid ini data
        /// 
        /// 
        ///     Text reader for the source string contaninig the ini data
        /// 
        /// 
        ///     An  instance containing the data readed
        ///     from the source
        /// 
        /// 
        ///     Thrown if the data could not be parsed
        ///        
        public void Parse(TextReader textReader, ref IniData iniData)
        {
            iniData.Clear();

            iniData.Scheme = Scheme.DeepClone();

            _errorExceptions.Clear();
            if (Configuration.ParseComments)
            {
                CurrentCommentListTemp.Clear();
            }
            _currentSectionNameTemp = null;
            _mBuffer.Reset(textReader);
            _currentLineNumber = 0;

            while (_mBuffer.ReadLine())
            {
                _currentLineNumber++;

                try
                {
                    ProcessLine(_mBuffer, iniData);
                }
                catch (Exception ex)
                {
                    _errorExceptions.Add(ex);
                    if (Configuration.ThrowExceptionsOnError)
                    {
                        throw;
                    }
                }
            }

            // TODO: is this try necessary?
            try
            {
                // Orphan comments, assing to last section/key value
                if (Configuration.ParseComments && CurrentCommentListTemp.Count > 0)
                {
                    if (iniData.Sections.Count > 0)
                    {
                        // Check if there are actually sections in the file
                        var sections = iniData.Sections;
                        var section = sections.FindByName(_currentSectionNameTemp);
                        section.Comments.AddRange(CurrentCommentListTemp);
                    }
                    else if (iniData.Global.Count > 0)
                    {
                        // No sections, put the comment in the last key value pair
                        // but only if the ini file contains at least one key-value pair
                        iniData.Global.GetLast().Comments.AddRange(CurrentCommentListTemp);
                    }

                    CurrentCommentListTemp.Clear();
                }

            }
            catch (Exception ex)
            {
                _errorExceptions.Add(ex);
                if (Configuration.ThrowExceptionsOnError)
                {
                    throw;
                }
            }

            if (HasError)
            {
                iniData.Clear();
            }
        }
    

开发者ID: rickyah,   项目名称: ini-parser,   代码行数: 86,   代码来源: IniDataParser.cs

在rickyah提供的Parse()方法中,该源代码示例一共有86行, 其中使用了TextReader.ReadLine()1次, 并且小编将这些方法高亮显示出来了,希望对您了解TextReader.ReadLine()有帮助。 如果您觉得有帮助的话,请帮忙点赞或转发。
该代码示例的点赞次数为3, 点赞数越大, 从某种程度说明这个示例对了解TextReader.ReadLine()可能更有帮助。

TextReader.ReadLine的代码示例3 - Parse()

    using System.IO;

        /// 从文本读写器中解析
        /// 
        /// 
        public Boolean Parse(TextReader reader)
        {
            var sb = new StringBuilder();
            var name = "";

            while (true)
            {
                var line = reader.ReadLine();
                if (line == null) break;

                if (!line.IsNullOrEmpty())
                {
                    // 识别数据库类型
                    if (line.StartsWith("--"))
                    {
                        var p1 = line.IndexOf('[');
                        var p2 = line.IndexOf(']');
                        if (p1 > 0 && p2 > p1)
                        {
                            // 完成一个sql片段,开始新的片段
                            if (sb.Length > 0)
                            {
                                if (name.IsNullOrEmpty())
                                    Sql = sb.ToString().Trim();
                                else
                                    Sqls[name] = sb.ToString().Trim();
                                sb.Clear();
                            }

                            name = line.Substring(p1 + 1, p2 - p1 - 1);
                            line = null;
                        }
                    }

                    if (line != null) sb.AppendLine(line);
                }
            }

            // 完成一个sql片段
            if (sb.Length > 0)
            {
                if (name.IsNullOrEmpty())
                    Sql = sb.ToString().Trim();
                else
                    Sqls[name] = sb.ToString().Trim();
            }

            return true;
        }
    

开发者ID: NewLifeX,   项目名称: X,   代码行数: 54,   代码来源: SqlTemplate.cs

在NewLifeX提供的Parse()方法中,该源代码示例一共有54行, 其中使用了TextReader.ReadLine()1次, 并且小编将这些方法高亮显示出来了,希望对您了解TextReader.ReadLine()有帮助。 如果您觉得有帮助的话,请帮忙点赞或转发。
该代码示例的点赞次数为3, 点赞数越大, 从某种程度说明这个示例对了解TextReader.ReadLine()可能更有帮助。

TextReader.ReadLine的代码示例4 - TestTruthFile()

    using System.IO;
        [Test]
        public void TestTruthFile()
        {
            Stream truthFile = HSSFTestDataSamples.OpenSampleFileStream("54686_fraction_formats.txt");
            TextReader reader = new StreamReader(truthFile);
            IWorkbook wb = HSSFTestDataSamples.OpenSampleWorkbook("54686_fraction_formats.xls");
            ISheet sheet = wb.GetSheetAt(0);
            DataFormatter formatter = new DataFormatter();
            IFormulaEvaluator Evaluator = wb.GetCreationHelper().CreateFormulaEvaluator();

            // Skip over the header row
            String truthLine = reader.ReadLine();
            String[] headers = truthLine.Split("\t".ToCharArray());
            truthLine = reader.ReadLine();

            for (int i = 1; i < sheet.LastRowNum && truthLine != null; i++)
            {
                IRow r = sheet.GetRow(i);
                String[] truths = truthLine.Split("\t".ToCharArray());
                // Intentionally ignore the last column (tika-1132), for now
                for (short j = 3; j < 12; j++)
                {
                    ICell cell = r.GetCell(j, MissingCellPolicy.CREATE_NULL_AS_BLANK);
                    String truth = Clean(truths[j]);
                    String testKey = truths[0] + ":" + truths[1] + ":" + headers[j];
                    String formatted = Clean(formatter.FormatCellValue(cell, Evaluator));
                    if (truths.Length <= j)
                    {
                        continue;
                    }

                    
                    Assert.AreEqual(truth, formatted, testKey);
                }
                truthLine = reader.ReadLine();
            }
            reader.Close();
        }
    

开发者ID: dotnetcore,   项目名称: NPOI,   代码行数: 39,   代码来源: TestFractionFormat.cs

在dotnetcore提供的TestTruthFile()方法中,该源代码示例一共有39行, 其中使用了TextReader.ReadLine()3次, 并且小编将这些方法高亮显示出来了,希望对您了解TextReader.ReadLine()有帮助。 如果您觉得有帮助的话,请帮忙点赞或转发。
该代码示例的点赞次数为3, 点赞数越大, 从某种程度说明这个示例对了解TextReader.ReadLine()可能更有帮助。

TextReader.ReadLine()方法的常见问题及解答

C#中TextReader.ReadLine()的常见错误类型及注意事项

TextReader.ReadLine的错误类型有很多, 这里就不一一阐述了,本文只列出一些常见的代码示例供参考,大家可以看一下代码中Catch语句中是否有常见的错误捕获及处理。

C#中TextReader.ReadLine()的构造函数有哪些

TextReader.ReadLine构造函数功能基本类似,只是参数不同; 目前主流的集成开发环境都已经带智能提醒了,如:Visual Studio; 大家可以非常轻松的通过Visual Studio中的智能提醒,了解对应构造函数的用法。

如何使用ChartGPT写一段TextReader.ReadLine的代码

你可以在ChartGPT中输入如下的指令:"提供一个如何使用TextReader.ReadLine的C#代码示例"
ChartGPT写出的代码和本文中的小编提供的代码的区别。 ChartGPT发展到现在已经非常聪明了,但需要使用这提供非常专业的问题,才可能有比较好的源代码示例; 而本文中, 小编已经帮您列出来基本所有类和所有方法的使用示例, 而且这些示例基本都是一些网络大佬提供的源码,可以更方便的供一些开发菜鸟或者资深开发参考和学习。

TextReader.ReadLine所在的类及名称空间

TextReader.ReadLine是System.IO下的方法。

TextReader.ReadLine怎么使用?

TextReader.ReadLine使用上比较简单,可以参考MSDN中的帮助文档,也参考本文中提供的5个使用示例。

TextReader.ReadLine菜鸟教程

对于菜鸟来说,本文中提供的5个TextReader.ReadLine写法都将非常直观的帮您掌握TextReader.ReadLine的用法,是一个不错的参考教程。

本文中的TextReader.ReadLine方法示例由csref.cn整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。