using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
namespace App
{
class Program
{
public static List<Types> List = new List<Types>();
static void Main(string[] args)
{
using (StreamReader read = new StreamReader(fileName.xml))
{
read.ReadLine();
while (!read.EndOfStream)
{
string line = read.ReadLine();
string[] splitline = line.Split('|');
Types t = new Types();
t.nbr = Convert.ToInt64(splitline[0].Trim());
t.addr = splitline[1].Trim().Length > 1 ? splitline[3] : "";
List.Add(t);
}
}
}
}
}
public class Types
{
public Types()
{
}
public long nbr { get; set; }
public string addr { get; set; }
}
I’m splitting the lines by ‘|’ and after the split the text does not contain any of these ‘|’ as well.
Its specifically happening at this line
t.addr = splitline[1].Trim().Length > 1 ? splitline[3] : "";
I don’t notice anything wrong with the text its parsing as I’m handle a null and such
Heres an example of what the text may look like:
3612|
1412|123 Circle st Miami,FL,87678
1420|
3587|23 Hamm st Chicago,IL,98678
Sorry I completely overlooked something it was happening when the line looked like this:
1420|jskljal,dfkjdklj
so splitline[1] definitely had text in it and it was because the line says this:
t.addr = splitline[1].Trim().Length > 1 ? splitline[3] <<<
I was seeing if splitLine[1] has length then selecting a splitline[3] which doesn’t exist.