Skip to main content
Code Review

Return to Answer

replaced http://meta.codereview.stackexchange.com/ with https://codereview.meta.stackexchange.com/
Source Link

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);
}
Source Link
Schism
  • 3.6k
  • 17
  • 31

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);
}
lang-cs

AltStyle によって変換されたページ (->オリジナル) /