No, you did not explain what do you want to write. What to do with line boundaries? Where to put ends of line on output? Where to put blank space? What is the sense of all this activity?
Let's forget it for now.
This is not how people write working code.
Do not immediate constants. In particular, don't use "", use
string.Empty
. Don't use immediate constant "10", make it a parameter of some function of constructor or explicit constant.
You don't need
ToCharArray
, it makes no sense, because
sequenceCount[i]
can be written as
fileContents[i]
.
Nothing is so bad for performance as string concatenation operator "+" in a loop. This is because strings are
immutable. When you append something to string, a brand new string object is created and the new reference is assigned to the variable on left of the assignment operator. Is causes copy of the whole string every time a string operation is called with ever growing string contents. This is very ineffective. You need to use
System.Text.StringBuilder
and its method
Append
or
AppendFormat
instead. See
http://msdn.microsoft.com/en-us/library/system.text.stringbuilder(v=VS.100).aspx[
^].
The method
Convert.ToString
makes no sense. A character can be appended to a string. From the previous paragraph you can see that you should use
System.Text.StringBuilder.Append
which also accepts character.
Should I continue? …Keep trying.
Any follow-up questions are welcome.
—SA