C# 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
在RawReadFirstLinesArray()方法中,TextReader的代码示例类中的ReadLine的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
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
在Parse()方法中,TextReader的代码示例类中的ReadLine的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
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
在Parse()方法中,TextReader的代码示例类中的ReadLine的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
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
在TestTruthFile()方法中,TextReader的代码示例类中的ReadLine的代码示例方法一共出现了3次, 见黄色背景高亮显示的地方,欢迎大家点赞
本文中的TextReader.ReadLine方法示例由csref.cn整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。