I have a string that has many line breaks and I want to build a string array that has each line of the string in an array slot.
Like this: stringArray[4] should have line 5 of the string in it.
I don't get an error in this code the string-array seems to have something in slot [0] the rest of the array seems to be empty:
using System;
namespace ProjectWebClientClass
{
class Program
{
static void Main(string[] args)
{
string htmlContent = String.Empty;
using (System.Net.WebClient client = new System.Net.WebClient())
{
//this method stores the html code in a string
htmlContent = client.DownloadString("http://www.rheinwerk-verlag.de");
}
Console.WriteLine(htmlContent);
string[] htmlLines = htmlContent.Split(Environment.NewLine);
//the following output is empty:
Console.WriteLine(htmlLines[4]);
}
}
}