Question by
TareqProjects · Aug 10, 2017 at 11:04 AM ·
c#
How do I remove carriage return on TextAsset?
Hello,
I current have a variable of type TextAsset. I am assigning the value to this variable by reading data from an external txt file, and then storing each entry into a List. The problem is that within this txt file there are carriage return (or is it newline? basically when you press enter and it starts on a new line) and they are also being added to my list. How do I populate my list without including the carraige return? I tried the following:
char[] carriageReturnChar = new char[] { '\r', '\n' };
ext_FIle.text.Split(carriageReturnChar,
System.StringSplitOptions.RemoveEmptyEntries);
System.IO.StringReader textStream = new System.IO.StringReader(ext_File.text);
while((line = textStream.ReadLine()) != null)
{
lineList.Add(line);
}
textStream.Close();
But when I do a debug.log at one of the list subscript, it returns an empty space.
Comment