Disclaimer: I'm not actually very familiar with C#. I'll also refrain from the style review I'll also refrain from the style review and let someone more familiar with common practices take a crack.
You can prepend 0
and append line.Length
to your array, simplifying the logic. There's probably a better way, but I got it working with a List
:
List<int> list = new List<int>();
list.Add(0);
list.AddRange(markers);
list.Add(line.Length);
for (int i = 0; i < list.Count - 1; i++)
{
string value = line.Substring(list[i], list[i + 1] - list[i]);
Console.WriteLine(value);
}
Disclaimer: I'm not actually very familiar with C#. I'll also refrain from the style review and let someone more familiar with common practices take a crack.
You can prepend 0
and append line.Length
to your array, simplifying the logic. There's probably a better way, but I got it working with a List
:
List<int> list = new List<int>();
list.Add(0);
list.AddRange(markers);
list.Add(line.Length);
for (int i = 0; i < list.Count - 1; i++)
{
string value = line.Substring(list[i], list[i + 1] - list[i]);
Console.WriteLine(value);
}
Disclaimer: I'm not actually very familiar with C#. I'll also refrain from the style review and let someone more familiar with common practices take a crack.
You can prepend 0
and append line.Length
to your array, simplifying the logic. There's probably a better way, but I got it working with a List
:
List<int> list = new List<int>();
list.Add(0);
list.AddRange(markers);
list.Add(line.Length);
for (int i = 0; i < list.Count - 1; i++)
{
string value = line.Substring(list[i], list[i + 1] - list[i]);
Console.WriteLine(value);
}
Disclaimer: I'm not actually very familiar with C#. I'll also refrain from the style review and let someone more familiar with common practices take a crack.
You can prepend 0
and append line.Length
to your array, simplifying the logic. There's probably a better way, but I got it working with a List
:
List<int> list = new List<int>();
list.Add(0);
list.AddRange(markers);
list.Add(line.Length);
for (int i = 0; i < list.Count - 1; i++)
{
string value = line.Substring(list[i], list[i + 1] - list[i]);
Console.WriteLine(value);
}