From 2a1cd4fda8a4a8e649910d16b4dfa1ce7ae63543 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Fri, 12 May 2023 09:24:40 +0800 Subject: *misc --- .../examples/reading/reading-by-hand/index.html | 463 +++++++++++++++++++++ 1 file changed, 463 insertions(+) create mode 100644 ThirdParty/CsvHelper-master/docs/examples/reading/reading-by-hand/index.html (limited to 'ThirdParty/CsvHelper-master/docs/examples/reading/reading-by-hand/index.html') diff --git a/ThirdParty/CsvHelper-master/docs/examples/reading/reading-by-hand/index.html b/ThirdParty/CsvHelper-master/docs/examples/reading/reading-by-hand/index.html new file mode 100644 index 0000000..dc8cb29 --- /dev/null +++ b/ThirdParty/CsvHelper-master/docs/examples/reading/reading-by-hand/index.html @@ -0,0 +1,463 @@ + + + + + + + + + + + + + + + + + + + + + + + Reading By Hand | CsvHelper + + + + + + + + + + + + + + + + +
+
+
+ + + +
+
+
+

Reading by Hand

+

Sometimes it's easier to not try and configure a mapping to match your class definition for various reasons. It's usually only a few more lines of code to just read the rows by hand instead.

+
Data
+
Id,Name
+1,one
+
+
Example
+
void Main()
+{
+    using (var reader = new StreamReader("path\\to\\file.csv"))
+    using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
+    {
+        var records = new List<Foo>();
+		csv.Read();
+		csv.ReadHeader();
+		while (csv.Read())
+		{
+			var record = new Foo
+			{
+				Id = csv.GetField<int>("Id"),
+				Name = csv.GetField("Name")
+			};
+			records.Add(record);
+		}
+    }
+}
+
+public class Foo
+{
+    public int Id { get; set; }
+    public string Name { get; set; }
+}
+
+ +
+
+
+
+ +

+ + + + + + + + + + + -- cgit v1.1-26-g67d0