-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
55 lines (46 loc) · 1.51 KB
/
Program.cs
File metadata and controls
55 lines (46 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
List<string[]> transactions = new();
List<string> currentTransaction = new();
using (FileStream fs = new FileStream("test.835", FileMode.Open, FileAccess.Read))
using (StreamReader reader = new StreamReader(fs))
{
string? line;
while ((line = await reader.ReadLineAsync()) != null)
{
if (line.StartsWith("ST*"))
{
currentTransaction = new List<string>();
}
currentTransaction.Add(line);
if (line.StartsWith("SE*"))
{
transactions.Add(currentTransaction.ToArray());
}
}
}
for (int i = 0; i < transactions.Count; i++)
{
bool hasN3 = false;
bool hasN4 = false;
foreach (var entry in transactions[i])
{
if (entry.StartsWith("N3*")) hasN3 = true;
if (entry.StartsWith("N4*")) hasN4 = true;
}
Console.WriteLine($"Transaction {i + 1}:");
foreach (var entry in transactions[i])
{
Console.WriteLine(entry);
}
Console.WriteLine($"Includes Address Information: {(hasN3 && hasN4 ? "Yes" : "No")}");
Console.WriteLine(new string('-', 40));
}
}
}