I am trying to convert a string to an array then back to a string again. I am trying to achieve this in C# but as i have not done C# in a while i am having issues. I created the following code in Java and it works fine:
String sHtml = "test1\r\ntest2\r\ntest3\r\ntest4\r\ntes5t\r\ntest6\r\ntest7\r\ntest8\r\ntest9\r\ntest10\r\ntest11\r\ntest12\r\ntest13\r\ntes14t\r\n";
int temp = 0;
List<String> emailText = new ArrayList<String>();
for(int x = 0; x<sHtml.length();x++){
if(sHtml.charAt(x)=='\n'){
emailText.add(sHtml.substring(temp, x));
temp = x;
}
}
String testingString="";
for(String words:emailText){
//System.out.println(words);
testingString+=words;
}
System.out.println(testingString);
This works fine in Java. The following code is what i have for C#:
int temp = 0;
List<string> emailText = new List<string>();
for (int x = 0; x < sHtml.Length; x++)
{
if (sHtml[x].Equals("\\n"))
{
emailText.Add(sHtml.Substring(temp, x));
temp = x;
}
else
{
}
}
string testingString = "";
//sHtml = string.Join("\r\n", emailText.ToArray());
foreach (String word in emailText)
{
testingString += word;
}
Console.WriteLine(testingString);
The java code outputs fine but i am getting no output from the C# code. I have a feeling i am missing something small from the C# code but i am not sure what, Can someone please help?
Thanks in advance
i am getting no output from the C# codeBecause you aren't printing. AddConsole.writeLine(testingString)at the end