edit as question is unanswered
I have a filtered output based on 1 criteria (first 3 numbers are 110,210 or 310,to give 3 distinct groups) to console from streamreader. Question edited because first answer was a literal solution to the specific example I gave, the real strings I'm using are 450 ASCII characters long. I have adjusted the example strings to remedy this, anything that works on the sample data will work on what I have.
so what i really need is something that can, depending on the first 3 numbers, take the 3 letters from a predesignated known location (for 210's it'll be character slot 14-16 and then using that as a subcategory, sum up all entries in character slot 33-37, and output those).
example strings:
210!!!!123244AAA75AWEHUIHJUAS!!!11111
210???1223455ABC76554HJHSDFQ????22222
210--32455623ABCFFCDGHDSFAS-----33333
310 1232451 2ABC34 GAERsASDFASDG1234523 44444
310 1234a354GDSAASDR 3 AAA GF234523653hfdssdgSDASDF 11111
310 12378HJK1234 ABC HJHJK123462 ASDHDFS FA REW 22222
4101111ASDJF 1ABCASF D1234 ASGF66666
4102222QW12362ER2 ABC 23459876HJKXC 11111
41033333T123 1RWE AAA ASDFHJKRTR WQ 22222
At the end of this, my output would be:
210 AAA 11111
210 ABC 55555
310 ABC 66666
310 AAA 11111
410 ABC 77777
410 AAA 22222
The ABC, AAA etc. are always in the same location for the same starting number, but will be different per starting number.
Likewise the location of the amounts being summed up are also only in the same place per each starting number.
I've tried adding some string.split to the existing code (below) but haven't had any luck.
// Read in a file line-by-line, and store in a List.
List<string> list = new List<string>();
using (StreamReader reader = new StreamReader("file.dat"))
{
string line;
while ((line = reader.ReadLine()) != null)
{
var beginning = line.Substring(0, 3);
if (beginning != "210" && beginning != "310" && beginning != "410")
continue;
list.Add(line); // Add to list.
Console.WriteLine(line); // Write to console.
}
}